diff options
Diffstat (limited to 'app/Model/Base.php')
-rw-r--r-- | app/Model/Base.php | 47 |
1 files changed, 42 insertions, 5 deletions
diff --git a/app/Model/Base.php b/app/Model/Base.php index 66185aeb..92578ffc 100644 --- a/app/Model/Base.php +++ b/app/Model/Base.php @@ -17,6 +17,8 @@ require __DIR__.'/../../vendor/SimpleValidator/Validators/Email.php'; require __DIR__.'/../../vendor/SimpleValidator/Validators/Numeric.php'; use Core\Event; +use Core\Tool; +use Core\Registry; use PicoDb\Database; /** @@ -24,6 +26,21 @@ use PicoDb\Database; * * @package model * @author Frederic Guillot + * + * @property \Model\Acl $acl + * @property \Model\Action $action + * @property \Model\Board $board + * @property \Model\Category $category + * @property \Model\Comment $comment + * @property \Model\Config $config + * @property \Model\File $file + * @property \Model\LastLogin $lastLogin + * @property \Model\Ldap $ldap + * @property \Model\Notification $notification + * @property \Model\Project $project + * @property \Model\SubTask $subTask + * @property \Model\Task $task + * @property \Model\User $user */ abstract class Base { @@ -44,15 +61,35 @@ abstract class Base protected $event; /** + * Registry instance + * + * @access protected + * @var \Core\Registry + */ + protected $registry; + + /** * Constructor * * @access public - * @param \PicoDb\Database $db Database instance - * @param \Core\Event $event Event dispatcher instance + * @param \Core\Registry $registry Registry instance + */ + public function __construct(Registry $registry) + { + $this->registry = $registry; + $this->db = $this->registry->shared('db'); + $this->event = $this->registry->shared('event'); + } + + /** + * Load automatically models + * + * @access public + * @param string $name Model name + * @return mixed */ - public function __construct(Database $db, Event $event) + public function __get($name) { - $this->db = $db; - $this->event = $event; + return Tool::loadModel($this->registry, $name); } } |