/** * @see \Vero\ACL\ACL::check() * @return boolean */ public function check($key, $role = null) { if (!$this->acl) { $this->acl = $this->container->get($this->service); } return $this->acl->check($key, $role); }
protected function create(Container $c) { if ($c->has('acl-backend')) { $backend = $c->get('acl-backend'); } else { $backend = new A\Backend\XML($c->get('app')->path('resources/acl/'), $c->get('cache')); } $acl = new A\ACL($backend); if ($c->has('auth')) { $acl->setSessionRole($c->get('auth')->getUser()); } return $acl; }
/** * Add PSR-3 Log listener form DI Container. * * @see \Vero\Log\Logger * @param Container * @param string * @return self */ public function addLogListener(Container $container, $key = 'log', $level = 'error') { $this->addListener(function ($data) use($container, $key, $level) { $container->get($key)->{$level}("Exception [{exception}]: '{message}'\n in {file}:{line}", $data); }); return $this; }
protected function create(Container $c) { $config = $c->get('config'); switch ($b = $config->get('session.backend', 'file')) { case 'database': $backend = new S\Backend\Database($c->get('doctrine')->getConnection(), $config->get('database.prefix') . 'session'); break; case 'file': $backend = new S\Backend\File($c->get('app')->path('var/session/')); break; default: throw new \RuntimeException("Session backend '{$b}' not recognized!"); } $session = new S\Session($backend, $config->get('session', [])); $session->start($c->get('request')); $c->get('controller')->addSendListener(array($session, 'close')); return $session; }
protected function create(Container $c) { $config = $c->get('config'); $prefix = $config->get('routing.prefix'); if ($c->has('request')) { $req = $c->get('request'); $domain = $config->get('routing.domain', $req->host()); $scheme = $config->get('routing.scheme', $req->scheme()); $base = $config->get('routing.base', $req->guessBase()); } else { $domain = $config->get('routing.domain'); $scheme = $config->get('routing.scheme'); $base = $config->get('routing.base', '/'); } $router = new Routing\Router($base, $prefix, $domain, $scheme); $builder = new Routing\Builder\XML($c->get('app')->path('resources/routes/'), $c->get('cache')); return $builder->fill($router); }
protected function create(Container $c) { $auth = new Manager($c->get('session'), $c->get('auth-provider'), $c->get('config')->get('session.autologin', true) && $c->has('autologin-provider') ? $c->get('autologin-provider') : null); $request = $c->get('request'); $c->get('controller')->addSendListener(function ($response) use($request, $auth) { $auth->visit($request); }); if ($auth->usesAutologin()) { $auth->addLoadListener(function ($user) use($request, $auth) { if ($user->isGuest()) { $auth->autologin($request); } }); } return $auth; }
protected function create(Container $c) { return new Log\Logger($c->get('config')->get('log.level', 'info'), new Log\Backend\File($c->get('app')->path('var/log/'), $c->get('config')->get('log.maxSize', Log\Backend\File::K128))); }
/** * Create instance of form from raw DI Container. * * @return self */ public static function create(Container $container) { return new static($container->get('request'), $container->get('session')); }
protected function create(Container $c) { return new Translator(new Xliff($c->get('cache'), $c->get('app')->path('resources/i18n/')), $c->get('config')->get('language', 'en'), $c->get('config')->get('languages', [])); }
protected function create(Container $c) { return new C(new FilesystemCache($c->get('app')->path('var/cache/'))); }
/** * Get instance of service from DI Container. * * @see Vero\DependencyInjection\Container.get() * @param string $name * @param mixed $args * @return mixed */ public function get($name, $args = []) { return $this->container->get($name, (array) $args); }