mirror of
https://github.com/espocrm/espocrm.git
synced 2026-06-28 06:56:05 +00:00
entry point manager use factory
This commit is contained in:
@@ -111,7 +111,10 @@ class Application
|
||||
|
||||
$slim->any('.*', function() {});
|
||||
|
||||
$entryPointManager = new \Espo\Core\EntryPointManager($container);
|
||||
$injectableFactory = $container->get('injectableFactory');
|
||||
$classFinder = $container->get('classFinder');
|
||||
|
||||
$entryPointManager = new \Espo\Core\EntryPointManager($injectableFactory, $classFinder);
|
||||
|
||||
try {
|
||||
$authRequired = $entryPointManager->checkAuthRequired($entryPoint);
|
||||
|
||||
@@ -29,29 +29,27 @@
|
||||
|
||||
namespace Espo\Core;
|
||||
|
||||
use Espo\Core\Exceptions\NotFound,
|
||||
Espo\Core\Utils\Util;
|
||||
use Espo\Core\Exceptions\NotFound;
|
||||
|
||||
use Espo\Core\{
|
||||
InjectableFactory,
|
||||
Utils\ClassFinder,
|
||||
};
|
||||
|
||||
class EntryPointManager
|
||||
{
|
||||
private $container;
|
||||
private $injectableFactory;
|
||||
|
||||
public function __construct(\Espo\Core\Container $container)
|
||||
public function __construct(InjectableFactory $injectableFactory, ClassFinder $classFinder)
|
||||
{
|
||||
$this->container = $container;
|
||||
}
|
||||
|
||||
protected function getContainer()
|
||||
{
|
||||
return $this->container;
|
||||
$this->injectableFactory = $injectableFactory;
|
||||
$this->classFinder = $classFinder;
|
||||
}
|
||||
|
||||
public function checkAuthRequired(string $name) : bool
|
||||
{
|
||||
$className = $this->getClassName($name);
|
||||
if (!$className) {
|
||||
echo $name;
|
||||
die;
|
||||
throw new NotFound();
|
||||
}
|
||||
return $className::$authRequired;
|
||||
@@ -72,7 +70,8 @@ class EntryPointManager
|
||||
if (!$className) {
|
||||
throw new NotFound();
|
||||
}
|
||||
$entryPoint = new $className($this->container);
|
||||
|
||||
$entryPoint = $this->injectableFactory->create($className);
|
||||
|
||||
$entryPoint->run($data);
|
||||
}
|
||||
@@ -80,6 +79,6 @@ class EntryPointManager
|
||||
protected function getClassName(string $name) : ?string
|
||||
{
|
||||
$name = ucfirst($name);
|
||||
return $this->getContainer()->get('classFinder')->find('EntryPoints', $name);
|
||||
return $this->classFinder->find('EntryPoints', $name);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user