From 3e18f488c60a81617a81149565d5d1f0cf50cb1d Mon Sep 17 00:00:00 2001 From: Yuri Kuznetsov Date: Sun, 7 May 2023 19:40:51 +0300 Subject: [PATCH] cs --- .../EntityManager/Hooks/BasePlusType.php | 36 ++++++++++--------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/application/Espo/Tools/EntityManager/Hooks/BasePlusType.php b/application/Espo/Tools/EntityManager/Hooks/BasePlusType.php index e357464a6c..d0b8ff071f 100644 --- a/application/Espo/Tools/EntityManager/Hooks/BasePlusType.php +++ b/application/Espo/Tools/EntityManager/Hooks/BasePlusType.php @@ -30,6 +30,7 @@ namespace Espo\Tools\EntityManager\Hooks; use Espo\Core\Di; +use Espo\Modules\Crm\Entities\Task; class BasePlusType implements Di\ConfigAware, Di\MetadataAware { @@ -39,12 +40,13 @@ class BasePlusType implements Di\ConfigAware, Di\MetadataAware /** * @param array $params */ - public function afterCreate(string $name, $params): void + public function afterCreate(string $name, array $params): void { $activitiesEntityTypeList = $this->config->get('activitiesEntityList', []); $historyEntityTypeList = $this->config->get('historyEntityList', []); + $entityTypeList = array_merge($activitiesEntityTypeList, $historyEntityTypeList); - $entityTypeList[] = 'Task'; + $entityTypeList[] = Task::ENTITY_TYPE; $entityTypeList = array_unique($entityTypeList); foreach ($entityTypeList as $entityType) { @@ -53,15 +55,16 @@ class BasePlusType implements Di\ConfigAware, Di\MetadataAware } $list = $this->metadata->get(['entityDefs', $entityType, 'fields', 'parent', 'entityList'], []); + if (!in_array($name, $list)) { $list[] = $name; - $data = array( - 'fields' => array( - 'parent' => array( - 'entityList' => $list - ) - ) - ); + + $data = [ + 'fields' => [ + 'parent' => ['entityList' => $list] + ] + ]; + $this->metadata->set('entityDefs', $entityType, $data); } } @@ -73,8 +76,9 @@ class BasePlusType implements Di\ConfigAware, Di\MetadataAware { $activitiesEntityTypeList = $this->config->get('activitiesEntityList', []); $historyEntityTypeList = $this->config->get('historyEntityList', []); + $entityTypeList = array_merge($activitiesEntityTypeList, $historyEntityTypeList); - $entityTypeList[] = 'Task'; + $entityTypeList[] = Task::ENTITY_TYPE; $entityTypeList = array_unique($entityTypeList); foreach ($entityTypeList as $entityType) { @@ -91,13 +95,11 @@ class BasePlusType implements Di\ConfigAware, Di\MetadataAware $list = array_values($list); - $data = array( - 'fields' => array( - 'parent' => array( - 'entityList' => $list - ) - ) - ); + $data = [ + 'fields' => [ + 'parent' => ['entityList' => $list] + ] + ]; $this->metadata->set('entityDefs', $entityType, $data); }