Merge "Clear the DBO_TRX flag for sanity in ExternalStore"
[mediawiki.git] / includes / resourceloader / DerivativeResourceLoaderContext.php
blobd114d7edb1ab0213b9fc79448052aa0a18f21a17
1 <?php
2 /**
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
20 * @file
21 * @author Kunal Mehta
24 /**
25 * Allows changing specific properties of a context object,
26 * without changing the main one. Inspired by DerivativeContext.
28 * @since 1.24
30 class DerivativeResourceLoaderContext extends ResourceLoaderContext {
32 /**
33 * @var ResourceLoaderContext
35 private $context;
36 protected $modules;
37 protected $language;
38 protected $direction;
39 protected $skin;
40 protected $user;
41 protected $debug;
42 protected $only;
43 protected $version;
44 protected $hash;
45 protected $raw;
47 public function __construct( ResourceLoaderContext $context ) {
48 $this->context = $context;
51 public function getModules() {
52 if ( !is_null( $this->modules ) ) {
53 return $this->modules;
54 } else {
55 return $this->context->getModules();
59 /**
60 * @param string[] $modules
62 public function setModules( array $modules ) {
63 $this->modules = $modules;
66 public function getLanguage() {
67 if ( !is_null( $this->language ) ) {
68 return $this->language;
69 } else {
70 return $this->context->getLanguage();
74 /**
75 * @param string $language
77 public function setLanguage( $language ) {
78 $this->language = $language;
79 $this->direction = null; // Invalidate direction since it might be based on language
80 $this->hash = null;
83 public function getDirection() {
84 if ( !is_null( $this->direction ) ) {
85 return $this->direction;
86 } else {
87 return $this->context->getDirection();
91 /**
92 * @param string $direction
94 public function setDirection( $direction ) {
95 $this->direction = $direction;
96 $this->hash = null;
99 public function getSkin() {
100 if ( !is_null( $this->skin ) ) {
101 return $this->skin;
102 } else {
103 return $this->context->getSkin();
108 * @param string $skin
110 public function setSkin( $skin ) {
111 $this->skin = $skin;
112 $this->hash = null;
115 public function getUser() {
116 if ( !is_null( $this->user ) ) {
117 return $this->user;
118 } else {
119 return $this->context->getUser();
124 * @param string $user
126 public function setUser( $user ) {
127 $this->user = $user;
128 $this->hash = null;
131 public function getDebug() {
132 if ( !is_null( $this->debug ) ) {
133 return $this->debug;
134 } else {
135 return $this->context->getDebug();
140 * @param bool $debug
142 public function setDebug( $debug ) {
143 $this->debug = $debug;
144 $this->hash = null;
147 public function getOnly() {
148 if ( !is_null( $this->only ) ) {
149 return $this->only;
150 } else {
151 return $this->context->getOnly();
156 * @param string $only
158 public function setOnly( $only ) {
159 $this->only = $only;
160 $this->hash = null;
163 public function getVersion() {
164 if ( !is_null( $this->version ) ) {
165 return $this->version;
166 } else {
167 return $this->context->getVersion();
172 * @param string $version
174 public function setVersion( $version ) {
175 $this->version = $version;
176 $this->hash = null;
179 public function getRaw() {
180 if ( !is_null( $this->raw ) ) {
181 return $this->raw;
182 } else {
183 return $this->context->getRaw();
188 * @param bool $raw
190 public function setRaw( $raw ) {
191 $this->raw = $raw;
194 public function getRequest() {
195 return $this->context->getRequest();
198 public function getResourceLoader() {
199 return $this->context->getResourceLoader();