From 39f018d99b07fb0509f4e3f20fb79dbc9fc894a4 Mon Sep 17 00:00:00 2001 From: Yuri Kuznetsov Date: Sat, 9 Nov 2024 13:32:41 +0200 Subject: [PATCH] remove deprecated injectable and base classes --- application/Espo/Core/Acl/Acl.php | 37 ---- application/Espo/Core/Acl/Base.php | 188 ---------------- application/Espo/Core/AclPortal/Acl.php | 38 ---- application/Espo/Core/AclPortal/Base.php | 201 ------------------ application/Espo/Core/Cleanup/Base.php | 64 ------ .../Espo/Core/Formula/Functions/Base.php | 42 +--- application/Espo/Core/Hooks/Base.php | 131 ------------ application/Espo/Core/Injectable.php | 88 -------- application/Espo/Core/InjectableFactory.php | 49 ----- .../Espo/Core/Interfaces/Injectable.php | 40 ---- .../Espo/Core/ORM/Repositories/RDB.php | 122 ----------- application/Espo/Core/ORM/Repository.php | 91 -------- application/Espo/Core/Services/Base.php | 107 ---------- 13 files changed, 1 insertion(+), 1197 deletions(-) delete mode 100644 application/Espo/Core/Acl/Acl.php delete mode 100644 application/Espo/Core/Acl/Base.php delete mode 100644 application/Espo/Core/AclPortal/Acl.php delete mode 100644 application/Espo/Core/AclPortal/Base.php delete mode 100644 application/Espo/Core/Cleanup/Base.php delete mode 100644 application/Espo/Core/Hooks/Base.php delete mode 100644 application/Espo/Core/Injectable.php delete mode 100644 application/Espo/Core/Interfaces/Injectable.php delete mode 100644 application/Espo/Core/ORM/Repositories/RDB.php delete mode 100644 application/Espo/Core/ORM/Repository.php delete mode 100644 application/Espo/Core/Services/Base.php diff --git a/application/Espo/Core/Acl/Acl.php b/application/Espo/Core/Acl/Acl.php deleted file mode 100644 index aee238ed00..0000000000 --- a/application/Espo/Core/Acl/Acl.php +++ /dev/null @@ -1,37 +0,0 @@ -. - * - * The interactive user interfaces in modified source and object code versions - * of this program must display Appropriate Legal Notices, as required under - * Section 5 of the GNU Affero General Public License version 3. - * - * In accordance with Section 7(b) of the GNU Affero General Public License version 3, - * these Appropriate Legal Notices must retain the display of the "EspoCRM" word. - ************************************************************************/ - -namespace Espo\Core\Acl; - -/** - * @deprecated As of v7.0. Use AccessChecker interfaces instead. - * @see https://docs.espocrm.com/development/metadata/acl-defs/ - */ -class Acl extends Base -{} diff --git a/application/Espo/Core/Acl/Base.php b/application/Espo/Core/Acl/Base.php deleted file mode 100644 index 68204cac61..0000000000 --- a/application/Espo/Core/Acl/Base.php +++ /dev/null @@ -1,188 +0,0 @@ -. - * - * The interactive user interfaces in modified source and object code versions - * of this program must display Appropriate Legal Notices, as required under - * Section 5 of the GNU Affero General Public License version 3. - * - * In accordance with Section 7(b) of the GNU Affero General Public License version 3, - * these Appropriate Legal Notices must retain the display of the "EspoCRM" word. - ************************************************************************/ - -namespace Espo\Core\Acl; - -use Espo\Core\Interfaces\Injectable; - -use Espo\ORM\Entity; -use Espo\Entities\User; -use Espo\Core\Acl\AccessChecker\ScopeChecker; -use Espo\Core\Acl\AccessChecker\ScopeCheckerData; -use Espo\Core\AclManager; -use Espo\Core\ORM\EntityManager; -use Espo\Core\Utils\Config; - -/** - * @deprecated As of v6.0. Use AccessChecker interfaces instead. - * @see https://docs.espocrm.com/development/metadata/acl-defs/ - */ -class Base implements AccessChecker, Injectable -{ - protected $dependencyList = []; /** @phpstan-ignore-line */ - - protected $dependencies = []; /** @phpstan-ignore-line */ - - protected $injections = []; /** @phpstan-ignore-line */ - - protected $entityManager; /** @phpstan-ignore-line */ - - protected $aclManager; /** @phpstan-ignore-line */ - - protected $config; /** @phpstan-ignore-line */ - - protected $defaultChecker; /** @phpstan-ignore-line */ - - protected $scopeChecker; /** @phpstan-ignore-line */ - - public function __construct( - EntityManager $entityManager, - AclManager $aclManager, - Config $config, - DefaultAccessChecker $defaultChecker, - ScopeChecker $scopeChecker - ) { - $this->entityManager = $entityManager; - $this->aclManager = $aclManager; - $this->config = $config; - $this->defaultChecker = $defaultChecker; - $this->scopeChecker = $scopeChecker; - - $this->init(); - } - - public function check(User $user, ScopeData $data): bool - { - return $this->defaultChecker->check($user, $data); - } - - public function checkEntity(User $user, Entity $entity, ScopeData $data, string $action): bool - { - $checkerData = ScopeCheckerData - ::createBuilder() - ->setIsOwnChecker( - function () use ($user, $entity): bool { - return (bool) $this->checkIsOwner($user, $entity); - } - ) - ->setInTeamChecker( - function () use ($user, $entity): bool { - return (bool) $this->checkInTeam($user, $entity); - } - ) - ->build(); - - return $this->scopeChecker->check($data, $action, $checkerData); - } - - public function checkScope(User $user, ScopeData $data, ?string $action = null): bool - { - if (!$action) { - return $this->defaultChecker->check($user, $data); - } - - if ($action === Table::ACTION_CREATE) { - return $this->defaultChecker->checkCreate($user, $data); - } - - if ($action === Table::ACTION_READ) { - return $this->defaultChecker->checkRead($user, $data); - } - - if ($action === Table::ACTION_EDIT) { - return $this->defaultChecker->checkEdit($user, $data); - } - - if ($action === Table::ACTION_DELETE) { - return $this->defaultChecker->checkDelete($user, $data); - } - - if ($action === Table::ACTION_STREAM) { - return $this->defaultChecker->checkStream($user, $data); - } - - return false; - } - - public function checkIsOwner(User $user, Entity $entity) /** @phpstan-ignore-line */ - { - return $this->aclManager->checkOwnershipOwn($user, $entity); - } - - public function checkInTeam(User $user, Entity $entity) /** @phpstan-ignore-line */ - { - return $this->aclManager->checkOwnershipTeam($user, $entity); - } - - public function inject($name, $object) /** @phpstan-ignore-line */ - { - $this->injections[$name] = $object; - } - - protected function init() /** @phpstan-ignore-line */ - { - } - - protected function getInjection($name) /** @phpstan-ignore-line */ - { - return $this->injections[$name] ?? $this->$name ?? null; - } - - protected function addDependencyList(array $list) /** @phpstan-ignore-line */ - { - foreach ($list as $item) { - $this->addDependency($item); - } - } - - protected function addDependency($name) /** @phpstan-ignore-line */ - { - $this->dependencyList[] = $name; - } - - public function getDependencyList() /** @phpstan-ignore-line */ - { - return array_merge($this->dependencyList, $this->dependencies); - } - - protected function getConfig(): Config - { - return $this->config; - } - - protected function getEntityManager(): EntityManager - { - return $this->entityManager; - } - - protected function getAclManager(): AclManager - { - return $this->aclManager; - } -} diff --git a/application/Espo/Core/AclPortal/Acl.php b/application/Espo/Core/AclPortal/Acl.php deleted file mode 100644 index 52a9a04746..0000000000 --- a/application/Espo/Core/AclPortal/Acl.php +++ /dev/null @@ -1,38 +0,0 @@ -. - * - * The interactive user interfaces in modified source and object code versions - * of this program must display Appropriate Legal Notices, as required under - * Section 5 of the GNU Affero General Public License version 3. - * - * In accordance with Section 7(b) of the GNU Affero General Public License version 3, - * these Appropriate Legal Notices must retain the display of the "EspoCRM" word. - ************************************************************************/ - -namespace Espo\Core\AclPortal; - -/** - * @deprecated Use AccessChecker interfaces instead. - */ -class Acl extends Base -{ - -} diff --git a/application/Espo/Core/AclPortal/Base.php b/application/Espo/Core/AclPortal/Base.php deleted file mode 100644 index 1d06c2368e..0000000000 --- a/application/Espo/Core/AclPortal/Base.php +++ /dev/null @@ -1,201 +0,0 @@ -. - * - * The interactive user interfaces in modified source and object code versions - * of this program must display Appropriate Legal Notices, as required under - * Section 5 of the GNU Affero General Public License version 3. - * - * In accordance with Section 7(b) of the GNU Affero General Public License version 3, - * these Appropriate Legal Notices must retain the display of the "EspoCRM" word. - ************************************************************************/ - -namespace Espo\Core\AclPortal; - -use Espo\Core\Interfaces\Injectable; -use Espo\ORM\Entity; -use Espo\Entities\User; -use Espo\Core\AclManager; -use Espo\Core\Acl\AccessChecker; -use Espo\Core\Acl\ScopeData; -use Espo\Core\ORM\EntityManager; -use Espo\Core\Portal\Acl\AccessChecker\ScopeChecker; -use Espo\Core\Portal\Acl\AccessChecker\ScopeCheckerData; -use Espo\Core\Portal\Acl\DefaultAccessChecker; -use Espo\Core\Portal\Acl\Table; -use Espo\Core\Portal\AclManager as PortalAclManager; -use Espo\Core\Utils\Config; - -/** - * @deprecated Use AccessChecker interfaces instead. - */ -class Base implements AccessChecker, Injectable -{ - protected $dependencyList = []; /** @phpstan-ignore-line */ - - protected $dependencies = []; /** @phpstan-ignore-line */ - - protected $injections = []; /** @phpstan-ignore-line */ - - protected $entityManager; /** @phpstan-ignore-line */ - - protected $aclManager; /** @phpstan-ignore-line */ - - protected $config; /** @phpstan-ignore-line */ - - protected $scopeChecker; /** @phpstan-ignore-line */ - - protected $defaultChecker; /** @phpstan-ignore-line */ - - public function __construct( - EntityManager $entityManager, - PortalAclManager $aclManager, - Config $config, - ScopeChecker $scopeChecker, - DefaultAccessChecker $defaultChecker - ) { - $this->entityManager = $entityManager; - $this->aclManager = $aclManager; - $this->config = $config; - $this->scopeChecker = $scopeChecker; - $this->defaultChecker = $defaultChecker; - - $this->init(); - } - - public function check(User $user, ScopeData $data): bool - { - return $this->defaultChecker->check($user, $data); - } - - public function checkEntity(User $user, Entity $entity, ScopeData $data, string $action): bool - { - $checkerData = ScopeCheckerData - ::createBuilder() - ->setIsOwnChecker( - function () use ($user, $entity): bool { - return (bool) $this->checkIsOwner($user, $entity); - } - ) - ->setInAccountChecker( - function () use ($user, $entity): bool { - return (bool) $this->checkInAccount($user, $entity); - } - ) - ->setInContactChecker( - function () use ($user, $entity): bool { - return (bool) $this->checkIsOwnContact($user, $entity); - } - ) - ->build(); - - return $this->scopeChecker->check($data, $action, $checkerData); - } - - public function checkScope(User $user, ScopeData $data, ?string $action = null): bool - { - if (!$action) { - return $this->defaultChecker->check($user, $data); - } - - if ($action === Table::ACTION_CREATE) { - return $this->defaultChecker->checkCreate($user, $data); - } - - if ($action === Table::ACTION_READ) { - return $this->defaultChecker->checkRead($user, $data); - } - - if ($action === Table::ACTION_EDIT) { - return $this->defaultChecker->checkEdit($user, $data); - } - - if ($action === Table::ACTION_DELETE) { - return $this->defaultChecker->checkDelete($user, $data); - } - - if ($action === Table::ACTION_STREAM) { - return $this->defaultChecker->checkStream($user, $data); - } - - return false; - } - - public function checkIsOwner(User $user, Entity $entity) /** @phpstan-ignore-line */ - { - return $this->aclManager->checkOwnershipOwn($user, $entity); - } - - public function checkInAccount(User $user, Entity $entity) /** @phpstan-ignore-line */ - { - return $this->aclManager->checkOwnershipAccount($user, $entity); - } - - public function checkIsOwnContact(User $user, Entity $entity) /** @phpstan-ignore-line */ - { - return $this->aclManager->checkOwnershipContact($user, $entity); - } - - protected function getConfig(): Config - { - return $this->config; - } - - protected function getEntityManager(): EntityManager - { - return $this->entityManager; - } - - protected function getAclManager(): AclManager - { - return $this->aclManager; - } - - public function inject($name, $object) /** @phpstan-ignore-line */ - { - $this->injections[$name] = $object; - } - - protected function init() /** @phpstan-ignore-line */ - { - } - - protected function getInjection($name) /** @phpstan-ignore-line */ - { - return $this->injections[$name] ?? $this->$name ?? null; - } - - protected function addDependencyList(array $list) /** @phpstan-ignore-line */ - { - foreach ($list as $item) { - $this->addDependency($item); - } - } - - protected function addDependency($name) /** @phpstan-ignore-line */ - { - $this->dependencyList[] = $name; - } - - public function getDependencyList() /** @phpstan-ignore-line */ - { - return array_merge($this->dependencyList, $this->dependencies); - } -} diff --git a/application/Espo/Core/Cleanup/Base.php b/application/Espo/Core/Cleanup/Base.php deleted file mode 100644 index 14ba5c30dc..0000000000 --- a/application/Espo/Core/Cleanup/Base.php +++ /dev/null @@ -1,64 +0,0 @@ -. - * - * The interactive user interfaces in modified source and object code versions - * of this program must display Appropriate Legal Notices, as required under - * Section 5 of the GNU Affero General Public License version 3. - * - * In accordance with Section 7(b) of the GNU Affero General Public License version 3, - * these Appropriate Legal Notices must retain the display of the "EspoCRM" word. - ************************************************************************/ - -namespace Espo\Core\Cleanup; - -/** @deprecated */ -abstract class Base extends \Espo\Core\Injectable -{ - protected function init() /** @phpstan-ignore-line */ - { - $this->addDependency('config'); - $this->addDependency('metadata'); - $this->addDependency('entityManager'); - $this->addDependency('fileManager'); - } - - protected function getConfig() /** @phpstan-ignore-line */ - { - return $this->getInjection('config'); - } - - protected function getMetadata() /** @phpstan-ignore-line */ - { - return $this->getInjection('metadata'); - } - - protected function getEntityManager() /** @phpstan-ignore-line */ - { - return $this->getInjection('entityManager'); - } - - protected function getFileManager() /** @phpstan-ignore-line */ - { - return $this->getInjection('fileManager'); - } - - abstract public function process(); /** @phpstan-ignore-line */ -} diff --git a/application/Espo/Core/Formula/Functions/Base.php b/application/Espo/Core/Formula/Functions/Base.php index b733e09541..e05c49d752 100644 --- a/application/Espo/Core/Formula/Functions/Base.php +++ b/application/Espo/Core/Formula/Functions/Base.php @@ -29,11 +29,8 @@ namespace Espo\Core\Formula\Functions; - use Espo\Core\Formula\Exceptions\Error; -use Espo\Core\Interfaces\Injectable; use Espo\ORM\Entity; - use Espo\Core\Formula\Processor; use Espo\Core\Formula\Argument; @@ -42,7 +39,7 @@ use stdClass; /** * @deprecated Use BaseFunction instead. */ -abstract class Base implements Injectable +abstract class Base { /** * @var ?string @@ -64,49 +61,12 @@ abstract class Base implements Injectable */ private $variables; - protected $dependencyList = []; /** @phpstan-ignore-line */ - - protected $injections = []; /** @phpstan-ignore-line */ - - public function inject($name, $object) /** @phpstan-ignore-line */ - { - $this->injections[$name] = $object; - } - - protected function getInjection($name) /** @phpstan-ignore-line */ - { - return $this->injections[$name] ?? $this->$name ?? null; - } - - protected function addDependency($name) /** @phpstan-ignore-line */ - { - $this->dependencyList[] = $name; - } - - protected function addDependencyList(array $list) /** @phpstan-ignore-line */ - { - foreach ($list as $item) { - $this->addDependency($item); - } - } - - public function getDependencyList() /** @phpstan-ignore-line */ - { - return $this->dependencyList; - } - public function __construct(string $name, Processor $processor, ?Entity $entity = null, ?stdClass $variables = null) { $this->name = $name; $this->processor = $processor; $this->entity = $entity; $this->variables = $variables; - - $this->init(); - } - - protected function init() /** @phpstan-ignore-line */ - { } protected function getVariables(): stdClass diff --git a/application/Espo/Core/Hooks/Base.php b/application/Espo/Core/Hooks/Base.php deleted file mode 100644 index 4500cadf88..0000000000 --- a/application/Espo/Core/Hooks/Base.php +++ /dev/null @@ -1,131 +0,0 @@ -. - * - * The interactive user interfaces in modified source and object code versions - * of this program must display Appropriate Legal Notices, as required under - * Section 5 of the GNU Affero General Public License version 3. - * - * In accordance with Section 7(b) of the GNU Affero General Public License version 3, - * these Appropriate Legal Notices must retain the display of the "EspoCRM" word. - ************************************************************************/ - -namespace Espo\Core\Hooks; - -use Espo\Core\Interfaces\Injectable; - -/** - * @deprecated As of v6.0. Not to be extended. Create plain classes with needed dependencies. - */ -abstract class Base implements Injectable -{ - protected $injections = []; /** @phpstan-ignore-line */ - - public static $order = 9; /** @phpstan-ignore-line */ - - /** @phpstan-ignore-next-line */ - protected $dependencyList = [ - 'container', - 'entityManager', - 'config', - 'metadata', - 'aclManager', - 'user', - 'serviceFactory', - ]; - - protected $dependencies = []; /** @phpstan-ignore-line */ - - public function __construct() - { - $this->init(); - } - - protected function init() /** @phpstan-ignore-line */ - { - } - - public function getDependencyList() /** @phpstan-ignore-line */ - { - return array_merge($this->dependencyList, $this->dependencies); - } - - protected function addDependencyList(array $list) /** @phpstan-ignore-line */ - { - foreach ($list as $item) { - $this->addDependency($item); - } - } - - protected function addDependency($name) /** @phpstan-ignore-line */ - { - $this->dependencyList[] = $name; - } - - protected function getInjection($name) /** @phpstan-ignore-line */ - { - return $this->injections[$name] ?? $this->$name ?? null; - } - - public function inject($name, $object) /** @phpstan-ignore-line */ - { - $this->injections[$name] = $object; - } - - protected function getContainer() /** @phpstan-ignore-line */ - { - return $this->getInjection('container'); - } - - protected function getEntityManager() /** @phpstan-ignore-line */ - { - return $this->getInjection('entityManager'); - } - - protected function getUser() /** @phpstan-ignore-line */ - { - return $this->getInjection('user'); - } - - protected function getAcl() /** @phpstan-ignore-line */ - { - return $this->getContainer()->get('acl'); - } - - protected function getAclManager() /** @phpstan-ignore-line */ - { - return $this->getInjection('aclManager'); - } - - protected function getConfig() /** @phpstan-ignore-line */ - { - return $this->getInjection('config'); - } - - protected function getMetadata() /** @phpstan-ignore-line */ - { - return $this->getInjection('metadata'); - } - - protected function getServiceFactory() /** @phpstan-ignore-line */ - { - return $this->getInjection('serviceFactory'); - } -} diff --git a/application/Espo/Core/Injectable.php b/application/Espo/Core/Injectable.php deleted file mode 100644 index 2f202a1544..0000000000 --- a/application/Espo/Core/Injectable.php +++ /dev/null @@ -1,88 +0,0 @@ -. - * - * The interactive user interfaces in modified source and object code versions - * of this program must display Appropriate Legal Notices, as required under - * Section 5 of the GNU Affero General Public License version 3. - * - * In accordance with Section 7(b) of the GNU Affero General Public License version 3, - * these Appropriate Legal Notices must retain the display of the "EspoCRM" word. - ************************************************************************/ - -namespace Espo\Core; - -/** - * @deprecated As of v6.0. Use the dependency injection framework. - */ -abstract class Injectable implements \Espo\Core\Interfaces\Injectable -{ - protected $dependencyList = []; /** @phpstan-ignore-line */ - - protected $injections = []; /** @phpstan-ignore-line */ - - public function inject($name, $object) /** @phpstan-ignore-line */ - { - $this->injections[$name] = $object; - } - - public function __construct() /** @phpstan-ignore-line */ - { - $this->init(); - } - - protected function init() /** @phpstan-ignore-line */ - { - } - - public function __call($methodName, $args) /** @phpstan-ignore-line */ - { - if (strpos($methodName, 'get') === 0) { - $injectionName = lcfirst(substr($methodName, 3)); - if (in_array($injectionName, $this->dependencyList)) { - return $this->getInjection($injectionName); - } - } - throw new \BadMethodCallException('Method ' . $methodName . ' does not exist'); - } - - protected function getInjection($name) /** @phpstan-ignore-line */ - { - return $this->injections[$name] ?? $this->$name ?? null; - } - - protected function addDependency($name) /** @phpstan-ignore-line */ - { - if (in_array($name, $this->dependencyList)) return; - $this->dependencyList[] = $name; - } - - protected function addDependencyList(array $list) /** @phpstan-ignore-line */ - { - foreach ($list as $item) { - $this->addDependency($item); - } - } - - public function getDependencyList() /** @phpstan-ignore-line */ - { - return $this->dependencyList; - } -} diff --git a/application/Espo/Core/InjectableFactory.php b/application/Espo/Core/InjectableFactory.php index c09e528e09..ab11e0495b 100644 --- a/application/Espo/Core/InjectableFactory.php +++ b/application/Espo/Core/InjectableFactory.php @@ -34,7 +34,6 @@ use Psr\Container\NotFoundExceptionInterface; use Espo\Core\Binding\BindingContainer; use Espo\Core\Binding\Binding; use Espo\Core\Binding\Factory; -use Espo\Core\Interfaces\Injectable; use ReflectionClass; use ReflectionParameter; @@ -171,13 +170,6 @@ class InjectableFactory $obj = $class->newInstanceArgs($injectionList); - // @todo Remove in v9.0. - if ($class->implementsInterface(Injectable::class)) { - $this->applyInjectable($class, $obj); - - return $obj; - } - $this->applyAwareInjections($class, $obj); return $obj; @@ -457,45 +449,4 @@ class InjectableFactory return false; } - - /** - * @deprecated As of v6.0. Use create or createWith methods instead. - * - * @template T of object - * @param class-string $className - * @param ?array $with - * @return T - */ - public function createByClassName(string $className, ?array $with = null): object - { - return $this->createInternal($className, $with); - } - - /** - * @deprecated - * @param ReflectionClass $class - * @todo Remove in v9.0. - */ - private function applyInjectable(ReflectionClass $class, object $obj): void - { - $setList = []; - - assert($obj instanceof Injectable); - - $dependencyList = $obj->getDependencyList(); - - foreach ($dependencyList as $name) { - $injection = $this->container->get($name); - - if ($this->classHasDependencySetter($class, $name)) { - $methodName = 'set' . ucfirst($name); - $obj->$methodName($injection); - $setList[] = $name; - } - - $obj->inject($name, $injection); - } - - $this->applyAwareInjections($class, $obj, $setList); - } } diff --git a/application/Espo/Core/Interfaces/Injectable.php b/application/Espo/Core/Interfaces/Injectable.php deleted file mode 100644 index 73e4dab800..0000000000 --- a/application/Espo/Core/Interfaces/Injectable.php +++ /dev/null @@ -1,40 +0,0 @@ -. - * - * The interactive user interfaces in modified source and object code versions - * of this program must display Appropriate Legal Notices, as required under - * Section 5 of the GNU Affero General Public License version 3. - * - * In accordance with Section 7(b) of the GNU Affero General Public License version 3, - * these Appropriate Legal Notices must retain the display of the "EspoCRM" word. - ************************************************************************/ - -namespace Espo\Core\Interfaces; - -/** - * @deprecated As of v6.0. Use the DI framework. - */ -interface Injectable -{ - public function getDependencyList(); /** @phpstan-ignore-line */ - - public function inject($name, $object); /** @phpstan-ignore-line */ -} diff --git a/application/Espo/Core/ORM/Repositories/RDB.php b/application/Espo/Core/ORM/Repositories/RDB.php deleted file mode 100644 index 1fc38a71b2..0000000000 --- a/application/Espo/Core/ORM/Repositories/RDB.php +++ /dev/null @@ -1,122 +0,0 @@ -. - * - * The interactive user interfaces in modified source and object code versions - * of this program must display Appropriate Legal Notices, as required under - * Section 5 of the GNU Affero General Public License version 3. - * - * In accordance with Section 7(b) of the GNU Affero General Public License version 3, - * these Appropriate Legal Notices must retain the display of the "EspoCRM" word. - ************************************************************************/ - -namespace Espo\Core\ORM\Repositories; - -use Espo\Core\ORM\EntityManager; -use Espo\Core\ORM\EntityFactory; -use Espo\Core\Interfaces\Injectable; -use Espo\Core\ApplicationState; -use Espo\Core\HookManager; -use Espo\Core\Utils\Id\RecordIdGenerator; -use Espo\Core\Utils\Metadata; -use Espo\Core\Utils\SystemUser; -use Espo\ORM\Relation\RelationsMap; - -/** - * @deprecated As of v6.0. Not to be extended. Extend Espo\Core\Repositories\Database, or better - * don't extend repositories at all. Use hooks. - */ -class RDB extends \Espo\Core\Repositories\Database implements Injectable /** @phpstan-ignore-line */ -{ - protected $dependencyList = [ /** @phpstan-ignore-line */ - 'config', - ]; - - protected $dependencies = []; /** @phpstan-ignore-line */ - - protected $injections = []; /** @phpstan-ignore-line */ - - protected function addDependency($name) /** @phpstan-ignore-line */ - { - $this->dependencyList[] = $name; - } - - protected function addDependencyList(array $list) /** @phpstan-ignore-line */ - { - foreach ($list as $item) { - $this->addDependency($item); - } - } - - public function inject($name, $object) /** @phpstan-ignore-line */ - { - $this->injections[$name] = $object; - } - - protected function getInjection($name) /** @phpstan-ignore-line */ - { - return $this->injections[$name] ?? $this->$name ?? null; - } - - public function getDependencyList() /** @phpstan-ignore-line */ - { - return array_merge($this->dependencyList, $this->dependencies); - } - - protected function getMetadata() /** @phpstan-ignore-line */ - { - return $this->getInjection('metadata'); - } - - protected function getConfig() /** @phpstan-ignore-line */ - { - return $this->getInjection('config'); - } - - public function __construct( - string $entityType, - EntityManager $entityManager, - EntityFactory $entityFactory, - Metadata $metadata, - HookManager $hookManager, - ApplicationState $applicationState, - RecordIdGenerator $recordIdGenerator, - SystemUser $systemUser, - ?RelationsMap $relationsMap, - ) { - parent::__construct( - $entityType, - $entityManager, - $entityFactory, - $metadata, - $hookManager, - $applicationState, - $recordIdGenerator, - $systemUser, - $relationsMap - ); - - $this->init(); - } - - protected function init() /** @phpstan-ignore-line */ - { - } -} diff --git a/application/Espo/Core/ORM/Repository.php b/application/Espo/Core/ORM/Repository.php deleted file mode 100644 index bd4e4e3249..0000000000 --- a/application/Espo/Core/ORM/Repository.php +++ /dev/null @@ -1,91 +0,0 @@ -. - * - * The interactive user interfaces in modified source and object code versions - * of this program must display Appropriate Legal Notices, as required under - * Section 5 of the GNU Affero General Public License version 3. - * - * In accordance with Section 7(b) of the GNU Affero General Public License version 3, - * these Appropriate Legal Notices must retain the display of the "EspoCRM" word. - ************************************************************************/ - -namespace Espo\Core\ORM; - -use Espo\Core\Interfaces\Injectable; - -use Espo\ORM\{ - EntityFactory, - Repository\RDBRepository as RDBRepository, -}; - -/** - * @deprecated As of v6.0. Not to be extended. Extend Espo\Core\Repositories\Database, or better - * don't extend repositories at all. Use hooks. - * @extends RDBRepository - */ -abstract class Repository extends RDBRepository implements Injectable -{ - protected $dependencyList = []; /** @phpstan-ignore-line */ - - protected $dependencies = []; /** @phpstan-ignore-line */ - - protected $injections = []; /** @phpstan-ignore-line */ - - protected function init() /** @phpstan-ignore-line */ - { - } - - public function inject($name, $object) /** @phpstan-ignore-line */ - { - $this->injections[$name] = $object; - } - - protected function getInjection($name) /** @phpstan-ignore-line */ - { - return $this->injections[$name]; - } - - public function getDependencyList() /** @phpstan-ignore-line */ - { - return array_merge($this->dependencyList, $this->dependencies); - } - - protected function addDependencyList(array $list) /** @phpstan-ignore-line */ - { - foreach ($list as $item) { - $this->addDependency($item); - } - } - - protected function addDependency($name) /** @phpstan-ignore-line */ - { - $this->dependencyList[] = $name; - } - - /** - * @param string $entityType - */ - public function __construct($entityType, EntityManager $entityManager, EntityFactory $entityFactory) - { - parent::__construct($entityType, $entityManager, $entityFactory); - $this->init(); - } -} diff --git a/application/Espo/Core/Services/Base.php b/application/Espo/Core/Services/Base.php deleted file mode 100644 index 6483b987ad..0000000000 --- a/application/Espo/Core/Services/Base.php +++ /dev/null @@ -1,107 +0,0 @@ -. - * - * The interactive user interfaces in modified source and object code versions - * of this program must display Appropriate Legal Notices, as required under - * Section 5 of the GNU Affero General Public License version 3. - * - * In accordance with Section 7(b) of the GNU Affero General Public License version 3, - * these Appropriate Legal Notices must retain the display of the "EspoCRM" word. - ************************************************************************/ - -namespace Espo\Core\Services; - -use Espo\Core\Interfaces\Injectable; - -/** - * @deprecated As of v6.0. Create plain classes with dependencies passed via constrictor. - */ -abstract class Base implements Injectable -{ - protected $dependencyList = [ /** @phpstan-ignore-line */ - 'config', - 'entityManager', - 'user', - 'serviceFactory', - ]; - - protected $injections = []; /** @phpstan-ignore-line */ - - public function inject($name, $object) /** @phpstan-ignore-line */ - { - $this->injections[$name] = $object; - } - - public function __construct() /** @phpstan-ignore-line */ - { - $this->init(); - } - - protected function init() /** @phpstan-ignore-line */ - { - } - - public function prepare() /** @phpstan-ignore-line */ - { - } - - protected function getInjection($name) /** @phpstan-ignore-line */ - { - return $this->injections[$name] ?? $this->$name ?? null; - } - - protected function addDependency($name) /** @phpstan-ignore-line */ - { - $this->dependencyList[] = $name; - } - - protected function addDependencyList(array $list) /** @phpstan-ignore-line */ - { - foreach ($list as $item) { - $this->addDependency($item); - } - } - - public function getDependencyList() /** @phpstan-ignore-line */ - { - return $this->dependencyList; - } - - protected function getEntityManager() /** @phpstan-ignore-line */ - { - return $this->getInjection('entityManager'); - } - - protected function getConfig() /** @phpstan-ignore-line */ - { - return $this->getInjection('config'); - } - - protected function getUser() /** @phpstan-ignore-line */ - { - return $this->getInjection('user'); - } - - protected function getServiceFactory() /** @phpstan-ignore-line */ - { - return $this->getInjection('serviceFactory'); - } -}