"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "framework/base/Controller.php" between
yii2-2.0.35.tar.gz and yii2-2.0.36.tar.gz

About: Yii 2 is a high-performance component-based PHP framework for developing large-scale Web applications (source).

Controller.php  (yii2-2.0.35):Controller.php  (yii2-2.0.36)
<?php <?php
/** /**
* @link http://www.yiiframework.com/ * @link http://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC * @copyright Copyright (c) 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/ * @license http://www.yiiframework.com/license/
*/ */
namespace yii\base; namespace yii\base;
use Yii; use Yii;
use yii\di\Instance;
use yii\di\NotInstantiableException;
/** /**
* Controller is the base class for classes containing controller logic. * Controller is the base class for classes containing controller logic.
* *
* For more details and usage information on Controller, see the [guide article on controllers](guide:structure-controllers). * For more details and usage information on Controller, see the [guide article on controllers](guide:structure-controllers).
* *
* @property Module[] $modules All ancestor modules that this controller is loca ted within. This property is * @property Module[] $modules All ancestor modules that this controller is loca ted within. This property is
* read-only. * read-only.
* @property string $route The route (module ID, controller ID and action ID) of the current request. This * @property string $route The route (module ID, controller ID and action ID) of the current request. This
* property is read-only. * property is read-only.
skipping to change at line 66 skipping to change at line 68
* This property mainly affects the behavior of [[render()]]. * This property mainly affects the behavior of [[render()]].
* Defaults to null, meaning the actual layout value should inherit that fro m [[module]]'s layout value. * Defaults to null, meaning the actual layout value should inherit that fro m [[module]]'s layout value.
* If false, no layout will be applied. * If false, no layout will be applied.
*/ */
public $layout; public $layout;
/** /**
* @var Action the action that is currently being executed. This property wi ll be set * @var Action the action that is currently being executed. This property wi ll be set
* by [[run()]] when it is called by [[Application]] to run an action. * by [[run()]] when it is called by [[Application]] to run an action.
*/ */
public $action; public $action;
/**
* @var Request|array|string The request.
* @since 2.0.36
*/
public $request = 'request';
/**
* @var Response|array|string The response.
* @since 2.0.36
*/
public $response = 'response';
/** /**
* @var View the view object that can be used to render views or view files. * @var View the view object that can be used to render views or view files.
*/ */
private $_view; private $_view;
/** /**
* @var string the root directory that contains view files for this controll er. * @var string the root directory that contains view files for this controll er.
*/ */
private $_viewPath; private $_viewPath;
skipping to change at line 89 skipping to change at line 101
* @param array $config name-value pairs that will be used to initialize the object properties. * @param array $config name-value pairs that will be used to initialize the object properties.
*/ */
public function __construct($id, $module, $config = []) public function __construct($id, $module, $config = [])
{ {
$this->id = $id; $this->id = $id;
$this->module = $module; $this->module = $module;
parent::__construct($config); parent::__construct($config);
} }
/** /**
* {@inheritdoc}
* @since 2.0.36
*/
public function init()
{
parent::init();
$this->request = Instance::ensure($this->request, Request::className());
$this->response = Instance::ensure($this->response, Response::className(
));
}
/**
* Declares external actions for the controller. * Declares external actions for the controller.
* *
* This method is meant to be overwritten to declare external actions for th e controller. * This method is meant to be overwritten to declare external actions for th e controller.
* It should return an array, with array keys being action IDs, and array va lues the corresponding * It should return an array, with array keys being action IDs, and array va lues the corresponding
* action class names or action configuration arrays. For example, * action class names or action configuration arrays. For example,
* *
* ```php * ```php
* return [ * return [
* 'action1' => 'app\components\Action1', * 'action1' => 'app\components\Action1',
* 'action2' => [ * 'action2' => [
skipping to change at line 525 skipping to change at line 548
if (pathinfo($file, PATHINFO_EXTENSION) !== '') { if (pathinfo($file, PATHINFO_EXTENSION) !== '') {
return $file; return $file;
} }
$path = $file . '.' . $view->defaultExtension; $path = $file . '.' . $view->defaultExtension;
if ($view->defaultExtension !== 'php' && !is_file($path)) { if ($view->defaultExtension !== 'php' && !is_file($path)) {
$path = $file . '.php'; $path = $file . '.php';
} }
return $path; return $path;
} }
/**
* Fills parameters based on types and names in action method signature.
* @param \ReflectionType $type The reflected type of the action parameter.
* @param string $name The name of the parameter.
* @param array &$args The array of arguments for the action, this function
may append items to it.
* @param array &$requestedParams The array with requested params, this func
tion may write specific keys to it.
* @throws ErrorException when we cannot load a required service.
* @throws InvalidConfigException Thrown when there is an error in the DI co
nfiguration.
* @throws NotInstantiableException Thrown when a definition cannot be resol
ved to a concrete class
* (for example an interface type hint) without a proper definition in the c
ontainer.
* @since 2.0.36
*/
final protected function bindInjectedParams(\ReflectionType $type, $name, &$
args, &$requestedParams)
{
// Since it is not a builtin type it must be DI injection.
$typeName = $type->getName();
if (($component = $this->module->get($name, false)) instanceof $typeName
) {
$args[] = $component;
$requestedParams[$name] = "Component: " . get_class($component) . "
\$$name";
} elseif ($this->module->has($typeName) && ($service = $this->module->ge
t($typeName)) instanceof $typeName) {
$args[] = $service;
$requestedParams[$name] = 'Module ' . get_class($this->module) . " D
I: $typeName \$$name";
} elseif (\Yii::$container->has($typeName) && ($service = \Yii::$contain
er->get($typeName)) instanceof $typeName) {
$args[] = $service;
$requestedParams[$name] = "Container DI: $typeName \$$name";
} elseif ($type->allowsNull()) {
$args[] = null;
$requestedParams[$name] = "Unavailable service: $name";
} else {
throw new Exception('Could not load required service: ' . $name);
}
}
} }
 End of changes. 4 change blocks. 
0 lines changed or deleted 68 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)