Example #1
0
 /**
  * Private constructor. Ensures there is always a owner group and user.
  *
  * @internal
  *
  * @param string  $environment (optional)
  * @param array   $context
  */
 private function __construct($environment = '', array $context = [])
 {
     $this->setEnvironment($environment, $context);
     $this->handlers = Application::getAuthorizationHandlers();
     foreach ($this->handlers as $handler) {
         $handler->handleContext($this->context);
     }
     // make sure, we always have user and group id of the owner
     if (!isset($this->context['request_user_id'])) {
         $this->context['request_user_id'] = Session::getUserId();
     }
     if (isset($this->context['request_user_id'])) {
         $this->isLoggedIn = $this->context['request_user_id'] > 0;
     }
     if (!isset($this->context['owner_user_id'])) {
         $this->context['owner_user_id'] = -1;
     }
     if (!isset($this->context['owner_group_id'])) {
         $this->context['owner_group_id'] = -1;
     }
 }