/**
  * @param Container $container The pimple DI container.
  * @return void
  */
 public function setDependencies(Container $container)
 {
     parent::setDependencies($container);
     $this->setAppConfig($container['config']);
     $this->setTranslationConfig($container['translator/config']);
 }
Ejemplo n.º 2
0
 /**
  * Template's init method is called automatically from `charcoal-app`'s Template Route.
  *
  * For admin templates, initializations is:
  *
  * - to start a session, if necessary
  * - to authenticate
  * - to initialize the template data with `$_GET`
  *
  * @param RequestInterface $request The request to initialize.
  * @return boolean
  * @see \Charcoal\App\Route\TemplateRoute::__invoke()
  */
 public function init(RequestInterface $request)
 {
     if (!session_id()) {
         session_cache_limiter(false);
         session_start();
     }
     if ($this->authRequired() !== false) {
         // This can reset headers / die if unauthorized.
         if (!$this->authenticator->authenticate()) {
             header('HTTP/1.0 403 Forbidden');
             header('Location: ' . $this->adminUrl() . 'login');
             exit;
         }
         // Initialize data with GET
         $this->setData($request->getParams());
         // Test template vs. ACL roles
         $authUser = $this->authenticator()->authenticate();
         if (!$this->authorizer()->userAllowed($authUser, $this->requiredAclPermissions())) {
             header('HTTP/1.0 403 Forbidden');
             header('Location: ' . $this->adminUrl() . 'login');
             exit;
         }
     } else {
         // Initialize data with GET
         $this->setData($request->getParams());
     }
     return parent::init($request);
 }