diff --git a/application/Espo/Core/ORM/ClassNameProvider.php b/application/Espo/Core/ORM/ClassNameProvider.php index 9e57ad217c..c52c33f80c 100644 --- a/application/Espo/Core/ORM/ClassNameProvider.php +++ b/application/Espo/Core/ORM/ClassNameProvider.php @@ -86,6 +86,13 @@ class ClassNameProvider */ private function findEntityClassName(string $entityType): string { + /** @var ?class-string $className */ + $className = $this->metadata->get("entityDefs.$entityType.entityClassName"); + + if ($className) { + return $className; + } + /** @var ?class-string $className */ $className = $this->classFinder->find('Entities', $entityType); @@ -114,6 +121,13 @@ class ClassNameProvider */ private function findRepositoryClassName(string $entityType): string { + /** @var ?class-string> $className */ + $className = $this->metadata->get("entityDefs.$entityType.repositoryClassName"); + + if ($className) { + return $className; + } + /** @var ?class-string> $className */ $className = $this->classFinder->find('Repositories', $entityType); diff --git a/application/Espo/Modules/Crm/Repositories/DocumentFolder.php b/application/Espo/Modules/Crm/Repositories/DocumentFolder.php deleted file mode 100644 index 1dcecd33d8..0000000000 --- a/application/Espo/Modules/Crm/Repositories/DocumentFolder.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\Modules\Crm\Repositories; - -/** - * @extends \Espo\Core\Repositories\CategoryTree<\Espo\Modules\Crm\Entities\DocumentFolder> - */ -class DocumentFolder extends \Espo\Core\Repositories\CategoryTree -{ -} diff --git a/application/Espo/Modules/Crm/Repositories/KnowledgeBaseCategory.php b/application/Espo/Modules/Crm/Repositories/KnowledgeBaseCategory.php deleted file mode 100644 index 744833671e..0000000000 --- a/application/Espo/Modules/Crm/Repositories/KnowledgeBaseCategory.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\Modules\Crm\Repositories; - -/** - * @extends \Espo\Core\Repositories\CategoryTree<\Espo\Modules\Crm\Entities\KnowledgeBaseCategory> - */ -class KnowledgeBaseCategory extends \Espo\Core\Repositories\CategoryTree -{ -} diff --git a/application/Espo/Modules/Crm/Resources/metadata/entityDefs/DocumentFolder.json b/application/Espo/Modules/Crm/Resources/metadata/entityDefs/DocumentFolder.json index b372c66b89..8c6ff139b7 100644 --- a/application/Espo/Modules/Crm/Resources/metadata/entityDefs/DocumentFolder.json +++ b/application/Espo/Modules/Crm/Resources/metadata/entityDefs/DocumentFolder.json @@ -98,5 +98,6 @@ } } } - } + }, + "repositoryClassName": "Espo\\Core\\Repositories\\CategoryTree" } diff --git a/application/Espo/Modules/Crm/Resources/metadata/entityDefs/KnowledgeBaseCategory.json b/application/Espo/Modules/Crm/Resources/metadata/entityDefs/KnowledgeBaseCategory.json index 59f4656529..f99ee1af9c 100644 --- a/application/Espo/Modules/Crm/Resources/metadata/entityDefs/KnowledgeBaseCategory.json +++ b/application/Espo/Modules/Crm/Resources/metadata/entityDefs/KnowledgeBaseCategory.json @@ -105,5 +105,6 @@ } } } - } + }, + "repositoryClassName": "Espo\\Core\\Repositories\\CategoryTree" } diff --git a/application/Espo/Repositories/EmailTemplateCategory.php b/application/Espo/Repositories/EmailTemplateCategory.php deleted file mode 100644 index 6ea594f596..0000000000 --- a/application/Espo/Repositories/EmailTemplateCategory.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\Repositories; - -use Espo\Core\Repositories\CategoryTree; - -/** - * @extends CategoryTree<\Espo\Entities\EmailTemplateCategory> - */ -class EmailTemplateCategory extends CategoryTree -{} diff --git a/application/Espo/Resources/metadata/entityDefs/EmailTemplateCategory.json b/application/Espo/Resources/metadata/entityDefs/EmailTemplateCategory.json index b79bd35224..91dcc87136 100644 --- a/application/Espo/Resources/metadata/entityDefs/EmailTemplateCategory.json +++ b/application/Espo/Resources/metadata/entityDefs/EmailTemplateCategory.json @@ -94,5 +94,6 @@ } } } - } + }, + "repositoryClassName": "Espo\\Core\\Repositories\\CategoryTree" } diff --git a/schema/metadata/entityDefs.json b/schema/metadata/entityDefs.json index ddf1bb3dcd..e2171c0699 100644 --- a/schema/metadata/entityDefs.json +++ b/schema/metadata/entityDefs.json @@ -83,6 +83,14 @@ "noDeletedAttribute": { "type": "boolean", "description": "Do not add the `deleted` attribute." + }, + "entityClassName": { + "type": "string", + "description": "An entity. Should implement Espo\\ORM\\Entity. Usually should extend Espo\\Core\\ORM\\Entity. As of v8.2." + }, + "repositoryClassName": { + "type": "string", + "description": "A repository. Should implement Espo\\ORM\\Repository\\Repository. As of v8.2." } }, "definitions": {