3 * Derivative context for resource loader modules.
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * http://www.gnu.org/copyleft/gpl.html
25 * Allows changing specific properties of a context object,
26 * without changing the main one. Inspired by DerivativeContext.
30 class DerivativeResourceLoaderContext
extends ResourceLoaderContext
{
31 const INHERIT_VALUE
= -1;
34 * @var ResourceLoaderContext
38 protected $modules = self
::INHERIT_VALUE
;
39 protected $language = self
::INHERIT_VALUE
;
40 protected $direction = self
::INHERIT_VALUE
;
41 protected $skin = self
::INHERIT_VALUE
;
42 protected $user = self
::INHERIT_VALUE
;
43 protected $debug = self
::INHERIT_VALUE
;
44 protected $only = self
::INHERIT_VALUE
;
45 protected $version = self
::INHERIT_VALUE
;
46 protected $raw = self
::INHERIT_VALUE
;
48 public function __construct( ResourceLoaderContext
$context ) {
49 $this->context
= $context;
52 public function getModules() {
53 if ( $this->modules
=== self
::INHERIT_VALUE
) {
54 return $this->context
->getModules();
56 return $this->modules
;
60 * @param string[] $modules
62 public function setModules( array $modules ) {
63 $this->modules
= $modules;
66 public function getLanguage() {
67 if ( $this->language
=== self
::INHERIT_VALUE
) {
68 return $this->context
->getLanguage();
70 return $this->language
;
74 * @param string $language
76 public function setLanguage( $language ) {
77 $this->language
= $language;
78 // Invalidate direction since it is based on language
79 $this->direction
= self
::INHERIT_VALUE
;
83 public function getDirection() {
84 if ( $this->direction
=== self
::INHERIT_VALUE
) {
85 return $this->context
->getDirection();
87 return $this->direction
;
91 * @param string $direction
93 public function setDirection( $direction ) {
94 $this->direction
= $direction;
98 public function getSkin() {
99 if ( $this->skin
=== self
::INHERIT_VALUE
) {
100 return $this->context
->getSkin();
106 * @param string $skin
108 public function setSkin( $skin ) {
113 public function getUser() {
114 if ( $this->user
=== self
::INHERIT_VALUE
) {
115 return $this->context
->getUser();
121 * @param string $user
123 public function setUser( $user ) {
126 $this->userObj
= null;
129 public function getDebug() {
130 if ( $this->debug
=== self
::INHERIT_VALUE
) {
131 return $this->context
->getDebug();
139 public function setDebug( $debug ) {
140 $this->debug
= $debug;
144 public function getOnly() {
145 if ( $this->only
=== self
::INHERIT_VALUE
) {
146 return $this->context
->getOnly();
152 * @param string|null $only
154 public function setOnly( $only ) {
159 public function getVersion() {
160 if ( $this->version
=== self
::INHERIT_VALUE
) {
161 return $this->context
->getVersion();
163 return $this->version
;
167 * @param string|null $version
169 public function setVersion( $version ) {
170 $this->version
= $version;
174 public function getRaw() {
175 if ( $this->raw
=== self
::INHERIT_VALUE
) {
176 return $this->context
->getRaw();
184 public function setRaw( $raw ) {
188 public function getRequest() {
189 return $this->context
->getRequest();
192 public function getResourceLoader() {
193 return $this->context
->getResourceLoader();