This repository has been archived on 2026-07-19. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
espocrm-base/application/Espo/Core/EntryPoints/Base.php
T
Yuri Kuznetsov 4094df2108 entryPoints
2014-01-21 13:04:59 +02:00

70 lines
1.1 KiB
PHP

<?php
namespace Espo\Core\EntryPoints;
use \Espo\Core\Container;
use \Espo\Core\Exceptions\Forbidden;
abstract class Base
{
private $container;
protected $authRequired = true;
protected function getContainer()
{
return $this->container;
}
protected function getUser()
{
return $this->getContainer()->get('user');
}
protected function getAcl()
{
return $this->getContainer()->get('acl');
}
protected function getEntityManager()
{
$this->getContainer()->get('entityManager');
}
protected function getServiceFactory()
{
$this->getContainer()->get('serviceFactory');
}
protected function getConfig()
{
return $this->getContainer()->get('config');
}
protected function getMetadata()
{
return $this->getContainer()->get('metadata');
}
protected function checkAccess()
{
if ($this->authRequired) {
return $this->getUser()->isFetched();
}
return false;
}
public function __construct(Container $container)
{
$this->container = $container;
if (!$this->checkAccess()) {
throw new Forbidden();
}
}
abstract public function run();
}