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 { return $this->name; } /** * Check access to controller. */ protected function checkAccess(): bool { return true; } /** * @throws Forbidden * @deprecated */ protected function checkControllerAccess() { return; } /** * @deprecated */ protected function getService($name): object { return $this->serviceFactory->create($name); } /** * @deprecated Use Aware interfaces to inject dependencies. * * @return \Espo\Core\Container */ protected function getContainer() { return $this->container; } /** * @deprecated * * @return \Espo\Entities\User */ protected function getUser() { return $this->container->get('user'); } /** * @deprecated * * @return \Espo\Core\Acl */ protected function getAcl() { return $this->container->get('acl'); } /** * @deprecated * * @return \Espo\Core\AclManager */ protected function getAclManager() { return $this->container->get('aclManager'); } /** * @deprecated * * @return \Espo\Core\Utils\Config */ protected function getConfig() { return $this->container->get('config'); } /** * @deprecated */ protected function getPreferences() { return $this->container->get('preferences'); } /** * @deprecated * * @return \Espo\Core\Utils\Metadata */ protected function getMetadata() { return $this->container->get('metadata'); } /** * @deprecated * * @return \Espo\Core\ServiceFactory */ protected function getServiceFactory() { return $this->container->get('serviceFactory'); } }