Update Action, Manager, Model

This commit is contained in:
Visman 2021-12-02 22:01:43 +07:00
parent b1c2abcc42
commit eafa30ff9e
3 changed files with 20 additions and 8 deletions

View file

@ -11,7 +11,7 @@ declare(strict_types=1);
namespace ForkBB\Models;
use ForkBB\Core\Container;
use ForkBB\Models\ManagerModel;
use ForkBB\Models\Manager;
class Action
{
@ -23,7 +23,7 @@ class Action
/**
* Модель
* @var ManagerModel
* @var Manager
*/
protected $manager;
@ -35,7 +35,7 @@ class Action
/**
* Объявление менеджера
*/
public function setManager(ManagerModel $manager): Action
public function setManager(Manager $manager): Action
{
$this->manager = $manager;

View file

@ -12,7 +12,7 @@ namespace ForkBB\Models;
use ForkBB\Core\Container;
class ManagerModel
class Manager
{
/**
* Контейнер
@ -20,6 +20,12 @@ class ManagerModel
*/
protected $c;
/**
* Ключ модели для контейнера
* @var string
*/
protected $cKey = 'unknown';
/**
* @var array
*/
@ -52,9 +58,9 @@ class ManagerModel
*/
public function __get(string $name) /* : mixed */
{
$key = \str_replace(['ForkBB\\Models\\', 'ForkBB\\', '\\'], '', \get_class($this));
$key = $this->cKey . '&' . $name;
return $this->c->{$key . \ucfirst($name)}->setManager($this);
return $this->c->$key->setManager($this);
}
/**

View file

@ -20,6 +20,12 @@ class Model
*/
protected $c;
/**
* Ключ модели для контейнера
* @var string
*/
protected $cKey = 'unknown';
/**
* Данные модели
* @var array
@ -157,8 +163,8 @@ class Model
*/
public function __call(string $name, array $args) /* : mixed */
{
$key = \str_replace(['ForkBB\\Models\\', 'ForkBB\\', '\\'], '', \get_class($this));
$key = $this->cKey . '*' . $name;
return $this->c->{$key . \ucfirst($name)}->setModel($this)->$name(...$args);
return $this->c->$key->setModel($this)->$name(...$args);
}
}