/**
* Group all the pieces relevant to the context of a request into one instance
*
+ * @since 1.18
+ *
* @author IAlex
* @author Daniel Friesen
* @file
*/
-class RequestContext implements IContextSource {
- private $mRequest; // / WebRequest object
- private $mTitle; // / Title object
- private $mOutput; // / OutputPage object
- private $mUser; // / User object
- private $mLang; // / Language object
- private $mSkin; // / Skin object
+class RequestContext {
+
+ /**
+ * @var WebRequest
+ */
+ private $mRequest;
+
+ /**
+ * @var Title
+ */
+ private $mTitle;
+
+ /**
+ * @var OutputPage
+ */
+ private $mOutput;
+
+ /**
+ * @var User
+ */
+ private $mUser;
+
+ /**
+ * @var Language
+ */
+ private $mLang;
+
+ /**
+ * @var Skin
+ */
+ private $mSkin;
/**
* Set the WebRequest object
return $this->mTitle;
}
+ /**
+ * @param $o OutputPage
+ */
+ public function setOutput( OutputPage $o ) {
+ $this->mOutput = $o;
+ }
+
/**
* Get the OutputPage object
*
* Make these C#-style accessors, so you can do $context->user->getName() which is
* internally mapped to $context->__get('user')->getName() which is mapped to
* $context->getUser()->getName()
+ *
+ * @param $name string
+ *
+ * @return string
*/
public function __get( $name ) {
+ wfDeprecated( 'RequestContext::__get() is deprecated; use $context->getFoo() instead' );
if ( in_array( $name, array( 'request', 'title', 'output', 'user', 'lang', 'skin' ) ) ) {
$fname = 'get' . ucfirst( $name );
return $this->$fname();
trigger_error( "Undefined property {$name}", E_NOTICE );
}
+ /**
+ * @param $name string
+ * @param $value
+ * @return string
+ */
public function __set( $name, $value ) {
+ wfDeprecated( 'RequestContext::__set() is deprecated; use $context->setFoo() instead' );
if ( in_array( $name, array( 'request', 'title', 'output', 'user', 'lang', 'skin' ) ) ) {
$fname = 'set' . ucfirst( $name );
return $this->$fname( $value );
}
}
-/**
- * Interface for objects which can provide a context on request.
- */
-interface IContextSource {
-
- /**
- * Get the WebRequest object
- *
- * @return WebRequest
- */
- public function getRequest();
-
- /**
- * Get the Title object
- *
- * @return Title
- */
- public function getTitle();
-
- /**
- * Get the OutputPage object
- *
- * @return OutputPage object
- */
- public function getOutput();
-
- /**
- * Get the User object
- *
- * @return User
- */
- public function getUser();
-
- /**
- * Get the Language object
- *
- * @return Language
- */
- public function getLang();
-
- /**
- * Get the Skin object
- *
- * @return Skin
- */
- public function getSkin();
-}
-
-/**
- * The simplest way of implementing IContextSource is to hold a RequestContext as a
- * member variable and provide accessors to it.
- */
-abstract class ContextSource implements IContextSource {
-
- /**
- * @var RequestContext
- */
- private $context;
-
- /**
- * Get the RequestContext object
- *
- * @return RequestContext
- */
- public function getContext() {
- return $this->context;
- }
-
- /**
- * Set the RequestContext object
- *
- * @param $context RequestContext
- */
- public function setContext( RequestContext $context ) {
- $this->context = $context;
- }
-
- /**
- * Get the WebRequest object
- *
- * @return WebRequest
- */
- public function getRequest() {
- return $this->context->getRequest();
- }
-
- /**
- * Get the Title object
- *
- * @return Title
- */
- public function getTitle() {
- return $this->context->getTitle();
- }
-
- /**
- * Get the OutputPage object
- *
- * @return OutputPage object
- */
- public function getOutput() {
- return $this->context->getOutput();
- }
-
- /**
- * Get the User object
- *
- * @return User
- */
- public function getUser() {
- return $this->context->getUser();
- }
-
- /**
- * Get the Language object
- *
- * @return Language
- */
- public function getLang() {
- return $this->context->getLang();
- }
-
- /**
- * Get the Skin object
- *
- * @return Skin
- */
- public function getSkin() {
- return $this->context->getSkin();
- }
-}
\ No newline at end of file