/** * Sets the name for the current session. * This is a wrapper for [PHP session_name()](http://php.net/manual/en/function.session-name.php). * @param string $value the session name for the current session, must be an alphanumeric string. * It defaults to "PHPSESSID". */ public function setName($value) { session_name($value); } /** * Gets the current session save path. * This is a wrapper for [PHP session_save_path()](http://php.net/manual/en/function.session-save-path.php). * @return string the current session save path, defaults to '/tmp'. */ public function getSavePath() {
* This is a wrapper for [PHP session_name()](http://php.net/manual/en/function.session-name.php). * @param string $value the session name for the current session, must be an alphanumeric string. * It defaults to "PHPSESSID". */ public function setName($value) { session_name($value); } /** * Gets the current session save path. * This is a wrapper for [PHP session_save_path()](http://php.net/manual/en/function.session-save-path.php). * @return string the current session save path, defaults to '/tmp'.
*/ public function __set($name, $value) { $setter = 'set' . $name; if (method_exists($this, $setter)) { // set property $this->$setter($value); return; } elseif (strncmp($name, 'on ', 3) === 0) { // on event: attach event handler $this->on(trim(substr($name, 3)), $value);
* @param array $properties the property initial values given in terms of name-value pairs. * @return object the object itself */ public static function configure($object, $properties) { foreach ($properties as $name => $value) { $object->$name = $value; } return $object; } /**
* * @param array $config name-value pairs that will be used to initialize the object properties */ public function __construct($config = []) { if (!empty($config)) { Yii::configure($this, $config); } $this->init(); } /** * Initializes the object.
return $reflection->newInstanceArgs($dependencies); } if (!empty($dependencies) && $reflection->implementsInterface('yii\base\Configurable')) { // set $config as the last parameter (existing one will be overwritten) $dependencies[count($dependencies) - 1] = $config; return $reflection->newInstanceArgs($dependencies); } $object = $reflection->newInstanceArgs($dependencies); foreach ($config as $name => $value) { $object->$name = $value; }
public function get($class, $params = [], $config = []) { if (isset($this->_singletons[$class])) { // singleton return $this->_singletons[$class]; } elseif (!isset($this->_definitions[$class])) { return $this->build($class, $params, $config); } $definition = $this->_definitions[$class]; if (is_callable($definition, true)) { $params = $this->resolveDependencies($this->mergeParams($class, $params));
{ if (is_string($type)) { return static::$container->get($type, $params); } elseif (is_array($type) && isset($type['class'])) { $class = $type['class']; unset($type['class']); return static::$container->get($class, $params, $type); } elseif (is_callable($type, true)) { return static::$container->invoke($type, $params); } elseif (is_array($type)) { throw new InvalidConfigException('Object configuration must be an array containing a "class" element.'); }
if (isset($this->_definitions[$id])) { $definition = $this->_definitions[$id]; if (is_object($definition) && !$definition instanceof Closure) { return $this->_components[$id] = $definition; } return $this->_components[$id] = Yii::createObject($definition); } elseif ($throwException) { throw new InvalidConfigException("Unknown component ID: $id"); } return null; }
* Since version 2.0.13, if a component isn't defined in the module, it will be looked up in the parent module. * The parent module may be the application. */ public function get($id, $throwException = true) { if (!isset($this->module)) { return parent::get($id, $throwException); } $component = parent::get($id, false); if ($component === null) { $component = $this->module->get($id, $throwException); }
/** * Returns the session component. * @return Session the session component. */ public function getSession() { return $this->get('session'); } /** * Returns the user component. * @return User the user component. */
* * If the user identity cannot be determined by session, this method will try to [[loginByCookie()|login by cookie]] * if [[enableAutoLogin]] is true. */ protected function renewAuthStatus() { $session = Yii::$app->getSession(); $id = $session->getHasSessionId() || $session->getIsActive() ? $session->get($this->idParam) : null; if ($id === null) { $identity = null; } else { /* @var $class IdentityInterface */
*/ public function getIdentity($autoRenew = true) { if ($this->_identity === false) { if ($this->enableSession && $autoRenew) { $this->_identity = null; $this->renewAuthStatus(); } else { return null; } } return $this->_identity;
* Returns a value indicating whether the user is a guest (not authenticated). * @return bool whether the current user is a guest. * @see getIdentity() */ public function getIsGuest() { return $this->getIdentity() === null; } /** * Returns a value that uniquely represents the user. * @return string|int the unique identifier for the user. If `null`, it means the user is a guest. * @see getIdentity()
*/ public function __get($name) { $getter = 'get' . $name; if (method_exists($this, $getter)) { // read property, e.g. getName() return $this->$getter(); } // behavior property $this->ensureBehaviors(); foreach ($this->_behaviors as $behavior) { if ($behavior->canGetProperty($name)) {
* @inheritdoc */ public function init() { if ( !$this->isEnabled() || Yii::$app->getUser()->isGuest ) { return; } $this->userSwitch = new UserSwitch(); $this->addAccesRules();
*/ public function __construct($config = []) { if (!empty($config)) { Yii::configure($this, $config); } $this->init(); } /** * Initializes the object. * This method is invoked at the end of the constructor after the object is initialized with the * given configuration.
return $reflection->newInstanceArgs($dependencies); } if (!empty($dependencies) && $reflection->implementsInterface('yii\base\Configurable')) { // set $config as the last parameter (existing one will be overwritten) $dependencies[count($dependencies) - 1] = $config; return $reflection->newInstanceArgs($dependencies); } $object = $reflection->newInstanceArgs($dependencies); foreach ($config as $name => $value) { $object->$name = $value; }
public function get($class, $params = [], $config = []) { if (isset($this->_singletons[$class])) { // singleton return $this->_singletons[$class]; } elseif (!isset($this->_definitions[$class])) { return $this->build($class, $params, $config); } $definition = $this->_definitions[$class]; if (is_callable($definition, true)) { $params = $this->resolveDependencies($this->mergeParams($class, $params));
{ if (is_string($type)) { return static::$container->get($type, $params); } elseif (is_array($type) && isset($type['class'])) { $class = $type['class']; unset($type['class']); return static::$container->get($class, $params, $type); } elseif (is_callable($type, true)) { return static::$container->invoke($type, $params); } elseif (is_array($type)) { throw new InvalidConfigException('Object configuration must be an array containing a "class" element.'); }
foreach ($this->panels as $id => $config) { if (is_string($config)) { $config = ['class' => $config]; } $config['module'] = $this; $config['id'] = $id; $this->panels[$id] = Yii::createObject($config); if ($this->panels[$id] instanceof Panel && !$this->panels[$id]->isEnabled()) { unset($this->panels[$id]); } } }
public function init() { parent::init(); $this->dataPath = Yii::getAlias($this->dataPath); if (Yii::$app instanceof \yii\web\Application) { $this->initPanels(); } } /** * Initializes panels. */
*/ public function __construct($config = []) { if (!empty($config)) { Yii::configure($this, $config); } $this->init(); } /** * Initializes the object. * This method is invoked at the end of the constructor after the object is initialized with the * given configuration.
* @param array $config name-value pairs that will be used to initialize the object properties. */ public function __construct($id, $parent = null, $config = []) { $this->id = $id; $this->module = $parent; parent::__construct($config); } /** * Returns the currently requested instance of this module class. * If the module class is not currently requested, `null` will be returned. * This method is provided so that you access the module instance from anywhere within the module.
$dependencies = $this->resolveDependencies($dependencies, $reflection); if (!$reflection->isInstantiable()) { throw new NotInstantiableException($reflection->name); } if (empty($config)) { return $reflection->newInstanceArgs($dependencies); } if (!empty($dependencies) && $reflection->implementsInterface('yii\base\Configurable')) { // set $config as the last parameter (existing one will be overwritten) $dependencies[count($dependencies) - 1] = $config; return $reflection->newInstanceArgs($dependencies);
public function get($class, $params = [], $config = []) { if (isset($this->_singletons[$class])) { // singleton return $this->_singletons[$class]; } elseif (!isset($this->_definitions[$class])) { return $this->build($class, $params, $config); } $definition = $this->_definitions[$class]; if (is_callable($definition, true)) { $params = $this->resolveDependencies($this->mergeParams($class, $params));
{ if (is_string($type)) { return static::$container->get($type, $params); } elseif (is_array($type) && isset($type['class'])) { $class = $type['class']; unset($type['class']); return static::$container->get($class, $params, $type); } elseif (is_callable($type, true)) { return static::$container->invoke($type, $params); } elseif (is_array($type)) { throw new InvalidConfigException('Object configuration must be an array containing a "class" element.'); }
if (isset($this->_modules[$id])) { if ($this->_modules[$id] instanceof self) { return $this->_modules[$id]; } elseif ($load) { Yii::trace("Loading module: $id", __METHOD__); /* @var $module Module */ $module = Yii::createObject($this->_modules[$id], [$id, $this]); $module->setInstance($module); return $this->_modules[$id] = $module; } } return null;
continue; } } elseif (is_string($mixed)) { if ($this->has($mixed)) { $component = $this->get($mixed); } elseif ($this->hasModule($mixed)) { $component = $this->getModule($mixed); } elseif (strpos($mixed, '\\') === false) { throw new InvalidConfigException("Unknown bootstrapping component ID: $mixed"); } } if (!isset($component)) {
protected function bootstrap() { $request = $this->getRequest(); Yii::setAlias('@webroot', dirname($request->getScriptFile())); Yii::setAlias('@web', $request->getBaseUrl()); parent::bootstrap(); } /** * Handles the specified request. * @param Request $request the request to be handled * @return Response the resulting response
/** * @inheritdoc */ public function init() { $this->state = self::STATE_INIT; $this->bootstrap(); } /** * Initializes extensions and executes bootstrap components. * This method is called by [[init()]] after the application has been fully configured. * If you override this method, make sure you also call the parent implementation.
*/ public function __construct($config = []) { if (!empty($config)) { Yii::configure($this, $config); } $this->init(); } /** * Initializes the object. * This method is invoked at the end of the constructor after the object is initialized with the * given configuration.
$this->state = self::STATE_BEGIN; $this->preInit($config); $this->registerErrorHandler($config); Component::__construct($config); } /** * Pre-initializes the application. * This method is called at the beginning of the application constructor. * It initializes several important application properties.
require(__DIR__ . '/../../common/config/main.php'), require(__DIR__ . '/../../common/config/main-local.php'), require(__DIR__ . '/../config/main.php'), require(__DIR__ . '/../config/main-local.php') ); (new yii\web\Application($config))->run();
$_GET = [ 'ver' => '765951', ];