refactoring

This commit is contained in:
Yuri Kuznetsov
2021-08-27 13:03:24 +03:00
parent 28a56c0bd7
commit 4c64b7e456
2 changed files with 10 additions and 6 deletions

View File

@@ -240,10 +240,14 @@ class Container implements ContainerInterface
private function load(string $name): void
{
$loadMethodName = 'load' . ucfirst($name);
if ($name === 'container') {
$this->setForced('container', $this->loadContainer());
if (method_exists($this, $loadMethodName)) {
$this->data[$name] = $this->$loadMethodName();
return;
}
if ($name === 'injectableFactory') {
$this->setForced('injectableFactory', $this->loadInjectableFactory());
return;
}
@@ -281,12 +285,12 @@ class Container implements ContainerInterface
$this->data[$name] = $this->injectableFactory->create($className);
}
protected function loadContainer(): Container
private function loadContainer(): Container
{
return $this;
}
protected function loadInjectableFactory(): InjectableFactory
private function loadInjectableFactory(): InjectableFactory
{
return new InjectableFactory($this, $this->bindingContainer);
}

View File

@@ -38,7 +38,7 @@ use Espo\Core\{
class Container extends BaseContainer
{
protected $portalIsSet = false;
private $portalIsSet = false;
public function setPortal(PortalEntity $portal): void
{