[ Index ]

PHP Cross Reference of MediaWiki-1.24.0

title

Body

[close]

/includes/resourceloader/ -> DerivativeResourceLoaderContext.php (source)

   1  <?php
   2  /**
   3   * Derivative context for resource loader modules.
   4   *
   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.
   9   *
  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.
  14   *
  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
  19   *
  20   * @file
  21   * @author Kunal Mehta
  22   */
  23  
  24  /**
  25   * Allows changing specific properties of a context object,
  26   * without changing the main one. Inspired by DerivativeContext.
  27   *
  28   * @since 1.24
  29   */
  30  class DerivativeResourceLoaderContext extends ResourceLoaderContext {
  31  
  32      /**
  33       * @var ResourceLoaderContext
  34       */
  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;
  46  
  47  	public function __construct( ResourceLoaderContext $context ) {
  48          $this->context = $context;
  49      }
  50  
  51  	public function getModules() {
  52          if ( !is_null( $this->modules ) ) {
  53              return $this->modules;
  54          } else {
  55              return $this->context->getModules();
  56          }
  57      }
  58  
  59      /**
  60       * @param string[] $modules
  61       */
  62  	public function setModules( array $modules ) {
  63          $this->modules = $modules;
  64      }
  65  
  66  	public function getLanguage() {
  67          if ( !is_null( $this->language ) ) {
  68              return $this->language;
  69          } else {
  70              return $this->context->getLanguage();
  71          }
  72      }
  73  
  74      /**
  75       * @param string $language
  76       */
  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;
  81      }
  82  
  83  	public function getDirection() {
  84          if ( !is_null( $this->direction ) ) {
  85              return $this->direction;
  86          } else {
  87              return $this->context->getDirection();
  88          }
  89      }
  90  
  91      /**
  92       * @param string $direction
  93       */
  94  	public function setDirection( $direction ) {
  95          $this->direction = $direction;
  96          $this->hash = null;
  97      }
  98  
  99  	public function getSkin() {
 100          if ( !is_null( $this->skin ) ) {
 101              return $this->skin;
 102          } else {
 103              return $this->context->getSkin();
 104          }
 105      }
 106  
 107      /**
 108       * @param string $skin
 109       */
 110  	public function setSkin( $skin ) {
 111          $this->skin = $skin;
 112          $this->hash = null;
 113      }
 114  
 115  	public function getUser() {
 116          if ( !is_null( $this->user ) ) {
 117              return $this->user;
 118          } else {
 119              return $this->context->getUser();
 120          }
 121      }
 122  
 123      /**
 124       * @param string $user
 125       */
 126  	public function setUser( $user ) {
 127          $this->user = $user;
 128          $this->hash = null;
 129      }
 130  
 131  	public function getDebug() {
 132          if ( !is_null( $this->debug ) ) {
 133              return $this->debug;
 134          } else {
 135              return $this->context->getDebug();
 136          }
 137      }
 138  
 139      /**
 140       * @param bool $debug
 141       */
 142  	public function setDebug( $debug ) {
 143          $this->debug = $debug;
 144          $this->hash = null;
 145      }
 146  
 147  	public function getOnly() {
 148          if ( !is_null( $this->only ) ) {
 149              return $this->only;
 150          } else {
 151              return $this->context->getOnly();
 152          }
 153      }
 154  
 155      /**
 156       * @param string $only
 157       */
 158  	public function setOnly( $only ) {
 159          $this->only = $only;
 160          $this->hash = null;
 161      }
 162  
 163  	public function getVersion() {
 164          if ( !is_null( $this->version ) ) {
 165              return $this->version;
 166          } else {
 167              return $this->context->getVersion();
 168          }
 169      }
 170  
 171      /**
 172       * @param string $version
 173       */
 174  	public function setVersion( $version ) {
 175          $this->version = $version;
 176          $this->hash = null;
 177      }
 178  
 179  	public function getRaw() {
 180          if ( !is_null( $this->raw ) ) {
 181              return $this->raw;
 182          } else {
 183              return $this->context->getRaw();
 184          }
 185      }
 186  
 187      /**
 188       * @param bool $raw
 189       */
 190  	public function setRaw( $raw ) {
 191          $this->raw = $raw;
 192      }
 193  
 194  	public function getRequest() {
 195          return $this->context->getRequest();
 196      }
 197  
 198  	public function getResourceLoader() {
 199          return $this->context->getResourceLoader();
 200      }
 201  
 202  }


Generated: Fri Nov 28 14:03:12 2014 Cross-referenced by PHPXref 0.7.1