container = $container; $this->user = $user; $this->acl = $acl; $this->aclManager = $aclManager; $this->config = $config; $this->preferences = $preferences; $this->metadata = $metadata; $this->serviceFactory = $serviceFactory; if (empty($this->name)) { $name = get_class($this); $matches = null; if (preg_match('@\\\\([\w]+)$@', $name, $matches)) { $name = $matches[1]; } $this->name = $name; } $this->checkControllerAccess(); if (!$this->checkAccess()) { throw new Forbidden("No access to '{$this->name}'."); } } /** * @deprecated */ protected function getName(): string { /** @var string */ return $this->name; } /** * Check access to controller. */ protected function checkAccess(): bool { return true; } /** * @return void; * @deprecated */ protected function checkControllerAccess() { return; } /** * @deprecated * @param string $name */ protected function getService($name): object { return $this->serviceFactory->create($name); } /** * @deprecated Use Aware interfaces to inject dependencies. * * @return Container */ protected function getContainer() { return $this->container; } /** * @deprecated * * @return User */ protected function getUser() { /** @var User */ return $this->container->get('user'); } /** * @deprecated * * @return Acl */ protected function getAcl() { /** @var Acl */ return $this->container->get('acl'); } /** * @deprecated * * @return AclManager */ protected function getAclManager() { /** @var AclManager */ return $this->container->get('aclManager'); } /** * @deprecated * * @return Config */ protected function getConfig() { /** @var Config */ return $this->container->get('config'); } /** * @deprecated * @return Preferences */ protected function getPreferences() { /** @var Preferences */ return $this->container->get('preferences'); } /** * @deprecated * * @return Metadata */ protected function getMetadata() { /** @var Metadata */ return $this->container->get('metadata'); } /** * @deprecated * * @return ServiceFactory */ protected function getServiceFactory() { /** @var ServiceFactory */ return $this->container->get('serviceFactory'); } }