From 6bb717d8a9d9f54c8424a4f81e6e8dbbc11a582e Mon Sep 17 00:00:00 2001 From: yuri Date: Fri, 25 Jan 2019 13:53:57 +0200 Subject: [PATCH] naming fix --- application/Espo/Core/Acl/Base.php | 14 +++++++----- application/Espo/Core/AclManager.php | 8 +++---- application/Espo/Core/HookManager.php | 17 +++++++------- application/Espo/Core/Hooks/Base.php | 22 ++++++++----------- application/Espo/Core/Notificators/Base.php | 14 ++++++------ .../Espo/Core/ORM/Repositories/RDB.php | 12 +++++----- application/Espo/Core/ORM/Repository.php | 11 +++++----- .../Espo/Core/ORM/RepositoryFactory.php | 5 ++--- application/Espo/Core/Portal/AclManager.php | 4 ++-- application/Espo/Core/ServiceFactory.php | 8 +++---- application/Espo/Core/Services/Base.php | 12 +++++----- .../Core/Utils/EntityManager/Hooks/Base.php | 4 ++-- .../Core/Utils/FieldManager/Hooks/Base.php | 6 ++--- application/Espo/Services/Record.php | 4 ++-- 14 files changed, 70 insertions(+), 71 deletions(-) diff --git a/application/Espo/Core/Acl/Base.php b/application/Espo/Core/Acl/Base.php index 11064c2711..a39ea6584b 100644 --- a/application/Espo/Core/Acl/Base.php +++ b/application/Espo/Core/Acl/Base.php @@ -36,15 +36,17 @@ use \Espo\ORM\Entity; class Base implements Injectable { - protected $dependencies = array( + protected $dependencyList = [ 'config', 'entityManager', - 'aclManager' - ); + 'aclManager', + ]; + + protected $dependencies = []; // for backward compatibility protected $scope; - protected $injections = array(); + protected $injections = []; protected $ownerUserIdAttribute = null; @@ -79,12 +81,12 @@ class Base implements Injectable protected function addDependency($name) { - $this->dependencies[] = $name; + $this->dependencyList[] = $name; } public function getDependencyList() { - return $this->dependencies; + return array_merge($this->dependencyList, $this->dependencies); } protected function getConfig() diff --git a/application/Espo/Core/AclManager.php b/application/Espo/Core/AclManager.php index 679b6f3b5d..713c7792ed 100644 --- a/application/Espo/Core/AclManager.php +++ b/application/Espo/Core/AclManager.php @@ -41,9 +41,9 @@ class AclManager private $metadata; - private $implementationHashMap = array(); + private $implementationHashMap = []; - private $tableHashMap = array(); + private $tableHashMap = []; protected $tableClassName = '\\Espo\\Core\\Acl\\Table'; @@ -93,8 +93,8 @@ class AclManager if (class_exists($className)) { $acl = new $className($scope); - $dependencies = $acl->getDependencyList(); - foreach ($dependencies as $name) { + $dependencyList = $acl->getDependencyList(); + foreach ($dependencyList as $name) { $acl->inject($name, $this->getContainer()->get($name)); } $this->implementationHashMap[$scope] = $acl; diff --git a/application/Espo/Core/HookManager.php b/application/Espo/Core/HookManager.php index 9cc27c8ca4..c2180abaef 100644 --- a/application/Espo/Core/HookManager.php +++ b/application/Espo/Core/HookManager.php @@ -37,7 +37,7 @@ class HookManager private $data; - private $hookListHash = array(); + private $hookListHash = []; private $hooks; @@ -48,18 +48,17 @@ class HookManager * * @var array */ - protected $ignoredMethodList = array( + protected $ignoredMethodList = [ '__construct', 'getDependencyList', - 'inject' - ); + 'inject', + ]; - protected $paths = array( + protected $paths = [ 'corePath' => 'application/Espo/Hooks', 'modulePath' => 'application/Espo/Modules/{*}/Hooks', 'customPath' => 'custom/Espo/Custom/Hooks', - ); - + ]; public function __construct(Container $container) { @@ -125,8 +124,8 @@ class HookManager { if (class_exists($className)) { $hook = new $className(); - $dependencies = $hook->getDependencyList(); - foreach ($dependencies as $name) { + $dependencyList = $hook->getDependencyList(); + foreach ($dependencyList as $name) { $hook->inject($name, $this->container->get($name)); } return $hook; diff --git a/application/Espo/Core/Hooks/Base.php b/application/Espo/Core/Hooks/Base.php index ee43422080..ad3d868f47 100644 --- a/application/Espo/Core/Hooks/Base.php +++ b/application/Espo/Core/Hooks/Base.php @@ -33,18 +33,20 @@ use Espo\Core\Interfaces\Injectable; abstract class Base implements Injectable { - protected $dependencies = array( + protected $injections = []; + + public static $order = 9; + + protected $dependencyList = [ 'container', 'entityManager', 'config', 'metadata', 'aclManager', 'user', - ); + ]; - protected $injections = array(); - - public static $order = 9; + protected $dependencies = []; // for backward compatibility public function __construct() { @@ -57,7 +59,7 @@ abstract class Base implements Injectable public function getDependencyList() { - return $this->dependencies; + return array_merge($this->dependencyList, $this->dependencies); } protected function addDependencyList(array $list) @@ -69,7 +71,7 @@ abstract class Base implements Injectable protected function addDependency($name) { - $this->dependencies[] = $name; + $this->dependencyList[] = $name; } protected function getInjection($name) @@ -116,10 +118,4 @@ abstract class Base implements Injectable { return $this->getInjection('metadata'); } - - protected function getRepository() - { - return $this->getEntityManager()->getRepository($this->entityName); - } } - diff --git a/application/Espo/Core/Notificators/Base.php b/application/Espo/Core/Notificators/Base.php index c15f635d64..9578aa4794 100644 --- a/application/Espo/Core/Notificators/Base.php +++ b/application/Espo/Core/Notificators/Base.php @@ -35,12 +35,12 @@ use \Espo\ORM\Entity; class Base implements Injectable { - protected $dependencies = array( + protected $dependencyList = [ 'user', 'entityManager', - ); + ]; - protected $injections = array(); + protected $injections = []; public static $order = 9; @@ -62,12 +62,12 @@ class Base implements Injectable protected function addDependency($name) { - $this->dependencies[] = $name; + $this->dependencyList[] = $name; } public function getDependencyList() { - return $this->dependencies; + return $this->dependencyList; } protected function getInjection($name) @@ -82,12 +82,12 @@ class Base implements Injectable protected function getEntityManager() { - return $this->injections['entityManager']; + return $this->getInjection('entityManager'); } protected function getUser() { - return $this->injections['user']; + return $this->getInjection('user'); } public function process(Entity $entity, array $options = []) diff --git a/application/Espo/Core/ORM/Repositories/RDB.php b/application/Espo/Core/ORM/Repositories/RDB.php index 43b8d13bdb..37068f186e 100644 --- a/application/Espo/Core/ORM/Repositories/RDB.php +++ b/application/Espo/Core/ORM/Repositories/RDB.php @@ -39,13 +39,15 @@ use \Espo\Core\Interfaces\Injectable; class RDB extends \Espo\ORM\Repositories\RDB implements Injectable { - protected $dependencies = array( + protected $dependencyList = [ 'metadata', 'config', 'fieldManagerUtil' - ); + ]; - protected $injections = array(); + protected $dependencies = []; // for backward compatibility + + protected $injections = []; private $restoreData = null; @@ -59,7 +61,7 @@ class RDB extends \Espo\ORM\Repositories\RDB implements Injectable protected function addDependency($name) { - $this->dependencies[] = $name; + $this->dependencyList[] = $name; } protected function addDependencyList(array $list) @@ -81,7 +83,7 @@ class RDB extends \Espo\ORM\Repositories\RDB implements Injectable public function getDependencyList() { - return $this->dependencies; + return array_merge($this->dependencyList, $this->dependencies); } protected function getMetadata() diff --git a/application/Espo/Core/ORM/Repository.php b/application/Espo/Core/ORM/Repository.php index 5f19427ae7..f1f68f9772 100644 --- a/application/Espo/Core/ORM/Repository.php +++ b/application/Espo/Core/ORM/Repository.php @@ -35,9 +35,11 @@ use \Espo\ORM\EntityFactory; abstract class Repository extends \Espo\ORM\Repository implements Injectable { - protected $dependencies = array(); + protected $dependencyList = []; - protected $injections = array(); + protected $dependencies = []; // for backward compatibility + + protected $injections = []; protected function init() { @@ -55,7 +57,7 @@ abstract class Repository extends \Espo\ORM\Repository implements Injectable public function getDependencyList() { - return $this->dependencies; + return array_merge($this->dependencyList, $this->dependencies); } protected function addDependencyList(array $list) @@ -67,7 +69,7 @@ abstract class Repository extends \Espo\ORM\Repository implements Injectable protected function addDependency($name) { - $this->dependencies[] = $name; + $this->dependencyList[] = $name; } public function __construct($entityType, EntityManager $entityManager, EntityFactory $entityFactory) @@ -76,4 +78,3 @@ abstract class Repository extends \Espo\ORM\Repository implements Injectable $this->init(); } } - diff --git a/application/Espo/Core/ORM/RepositoryFactory.php b/application/Espo/Core/ORM/RepositoryFactory.php index 6786179919..c25df4adba 100644 --- a/application/Espo/Core/ORM/RepositoryFactory.php +++ b/application/Espo/Core/ORM/RepositoryFactory.php @@ -37,11 +37,10 @@ class RepositoryFactory extends \Espo\ORM\RepositoryFactory { $repository = parent::create($name); - $dependencies = $repository->getDependencyList(); - foreach ($dependencies as $name) { + $dependencyList = $repository->getDependencyList(); + foreach ($dependencyList as $name) { $repository->inject($name, $this->entityManager->getContainer()->get($name)); } return $repository; } } - diff --git a/application/Espo/Core/Portal/AclManager.php b/application/Espo/Core/Portal/AclManager.php index 7d7d8e1990..1b4877fa51 100644 --- a/application/Espo/Core/Portal/AclManager.php +++ b/application/Espo/Core/Portal/AclManager.php @@ -63,8 +63,8 @@ class AclManager extends \Espo\Core\AclManager if (class_exists($className)) { $acl = new $className($scope); - $dependencies = $acl->getDependencyList(); - foreach ($dependencies as $name) { + $dependencyList = $acl->getDependencyList(); + foreach ($dependencyList as $name) { $acl->inject($name, $this->getContainer()->get($name)); } $this->implementationHashMap[$scope] = $acl; diff --git a/application/Espo/Core/ServiceFactory.php b/application/Espo/Core/ServiceFactory.php index 51df67e39e..2f933d04cc 100644 --- a/application/Espo/Core/ServiceFactory.php +++ b/application/Espo/Core/ServiceFactory.php @@ -41,11 +41,11 @@ class ServiceFactory /** * @var array - path to Service files */ - protected $paths = array( + protected $paths = [ 'corePath' => 'application/Espo/Services', 'modulePath' => 'application/Espo/Modules/{*}/Services', 'customPath' => 'custom/Espo/Custom/Services', - ); + ]; protected $data; @@ -104,8 +104,8 @@ class ServiceFactory { if (class_exists($className)) { $service = new $className(); - $dependencies = $service->getDependencyList(); - foreach ($dependencies as $name) { + $dependencyList = $service->getDependencyList(); + foreach ($dependencyList as $name) { $service->inject($name, $this->container->get($name)); } if (method_exists($service, 'prepare')) { diff --git a/application/Espo/Core/Services/Base.php b/application/Espo/Core/Services/Base.php index cca6960676..769d7a97f1 100644 --- a/application/Espo/Core/Services/Base.php +++ b/application/Espo/Core/Services/Base.php @@ -33,14 +33,14 @@ use \Espo\Core\Interfaces\Injectable; abstract class Base implements Injectable { - protected $dependencies = array( + protected $dependencyList = [ 'config', 'entityManager', 'user', - 'serviceFactory' - ); + 'serviceFactory', + ]; - protected $injections = array(); + protected $injections = []; public function inject($name, $object) { @@ -67,7 +67,7 @@ abstract class Base implements Injectable protected function addDependency($name) { - $this->dependencies[] = $name; + $this->dependencyList[] = $name; } protected function addDependencyList(array $list) @@ -79,7 +79,7 @@ abstract class Base implements Injectable public function getDependencyList() { - return $this->dependencies; + return $this->dependencyList; } protected function getEntityManager() diff --git a/application/Espo/Core/Utils/EntityManager/Hooks/Base.php b/application/Espo/Core/Utils/EntityManager/Hooks/Base.php index ced40a41ad..11246887ab 100644 --- a/application/Espo/Core/Utils/EntityManager/Hooks/Base.php +++ b/application/Espo/Core/Utils/EntityManager/Hooks/Base.php @@ -1,4 +1,4 @@ -dependencies[] = $name; + $this->dependencyList[] = $name; } protected function getInjection($name) diff --git a/application/Espo/Core/Utils/FieldManager/Hooks/Base.php b/application/Espo/Core/Utils/FieldManager/Hooks/Base.php index ea34572897..63a0880c84 100644 --- a/application/Espo/Core/Utils/FieldManager/Hooks/Base.php +++ b/application/Espo/Core/Utils/FieldManager/Hooks/Base.php @@ -1,4 +1,4 @@ -dependencies[] = $name; + $this->dependencyList[] = $name; } protected function getInjection($name) @@ -89,4 +89,4 @@ abstract class Base { return $this->getInjection('entityManager'); } -} \ No newline at end of file +} diff --git a/application/Espo/Services/Record.php b/application/Espo/Services/Record.php index 5b81844f6c..b0fa2cf0e1 100644 --- a/application/Espo/Services/Record.php +++ b/application/Espo/Services/Record.php @@ -42,7 +42,7 @@ use \Espo\Core\Utils\Util; class Record extends \Espo\Core\Services\Base { - protected $dependencies = [ + protected $dependencyList = [ 'entityManager', 'user', 'metadata', @@ -54,7 +54,7 @@ class Record extends \Espo\Core\Services\Base 'selectManagerFactory', 'fileStorageManager', 'injectableFactory', - 'fieldManagerUtil' + 'fieldManagerUtil', ]; protected $getEntityBeforeUpdate = false;