refactor: Замена строк на имена классов
This commit is contained in:
parent
1d22953f68
commit
82f6dd1630
4 changed files with 30 additions and 18 deletions
|
|
@ -98,7 +98,7 @@ class Action
|
|||
/**
|
||||
* Создает представление
|
||||
* @param string $name
|
||||
* @param string $viewClass
|
||||
* @param class-string $viewClass
|
||||
* @return Composite
|
||||
*/
|
||||
public function getView($name, $viewClass = Composite::class)
|
||||
|
|
@ -146,6 +146,11 @@ class Action
|
|||
return $tpl;
|
||||
}
|
||||
|
||||
/**
|
||||
* @template T
|
||||
* @param class-string<T> $name
|
||||
* @return T
|
||||
*/
|
||||
public function getModel($name)
|
||||
{
|
||||
if (!$this->factory) {
|
||||
|
|
|
|||
|
|
@ -99,7 +99,8 @@ class Component
|
|||
return new FakeTemplate($name);
|
||||
}
|
||||
|
||||
$config/*: Registry*/ = $this->config;
|
||||
/* @var Registry $config */
|
||||
$config = $this->config;
|
||||
$default = $config->get('site', 'template');
|
||||
$template = ($this->template) ? $this->template : $this->getTemplateName($config);
|
||||
|
||||
|
|
|
|||
|
|
@ -9,7 +9,9 @@ use Exception,
|
|||
ctiso\Collection,
|
||||
ctiso\Session;
|
||||
|
||||
// HTTPRequest = ArrayAccess
|
||||
/**
|
||||
* @template T
|
||||
*/
|
||||
class HttpRequest extends Collection
|
||||
{
|
||||
|
||||
|
|
@ -44,6 +46,10 @@ class HttpRequest extends Collection
|
|||
return parent::get($key);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param T $key
|
||||
* @return mixed
|
||||
*/
|
||||
function get($key, $default = null)
|
||||
{
|
||||
return parent::get('data')->get($key, $default);
|
||||
|
|
|
|||
|
|
@ -20,12 +20,12 @@ class Factory
|
|||
|
||||
/**
|
||||
* Создает модель
|
||||
* @param string $name
|
||||
* @return BaseMapper
|
||||
* @template T
|
||||
* @param class-string<T> $modelName
|
||||
* @return T
|
||||
*/
|
||||
public function getModel ($name)
|
||||
public function getModel($modelName)
|
||||
{
|
||||
$modelName = "App\\Mapper\\" . $name;
|
||||
$model = new $modelName();
|
||||
$model->db = $this->db;
|
||||
$model->factory = $this;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue