. */ namespace SP\Repositories; use SP\Bootstrap; use SP\Config\Config; use SP\Core\Events\EventDispatcher; use SP\Core\Session\Session; use SP\Storage\Database; use SP\Storage\DatabaseInterface; /** * Class Repository * * @package SP\Repositories */ abstract class Repository { /** @var Config */ protected $config; /** @var Session */ protected $session; /** @var EventDispatcher */ protected $eventDispatcher; /** @var DatabaseInterface */ protected $db; /** * Repository constructor. * * @throws \Psr\Container\ContainerExceptionInterface * @throws \Psr\Container\NotFoundExceptionInterface */ final public function __construct() { $dic = Bootstrap::getContainer(); $this->config = $dic->get(Config::class); $this->db = $dic->get(Database::class); $this->session = $dic->get(Session::class); $this->eventDispatcher = $dic->get(EventDispatcher::class); if (method_exists($this, 'initialize')) { $this->initialize(); } } }