entity manager ref
This commit is contained in:
Generated
+19
@@ -797,6 +797,25 @@
|
||||
</SchemaInfo>
|
||||
</value>
|
||||
</entry>
|
||||
<entry key="metadata/app/entityManager">
|
||||
<value>
|
||||
<SchemaInfo>
|
||||
<option name="generatedName" value="New Schema" />
|
||||
<option name="name" value="metadata/app/entityManager" />
|
||||
<option name="relativePathToSchema" value="schema/metadata/app/entityManager.json" />
|
||||
<option name="schemaVersion" value="JSON Schema version 7" />
|
||||
<option name="patterns">
|
||||
<list>
|
||||
<Item>
|
||||
<option name="pattern" value="true" />
|
||||
<option name="path" value="*/Resources/metadata/app/entityManager.json" />
|
||||
<option name="mappingKind" value="Pattern" />
|
||||
</Item>
|
||||
</list>
|
||||
</option>
|
||||
</SchemaInfo>
|
||||
</value>
|
||||
</entry>
|
||||
<entry key="metadata/app/massActions">
|
||||
<value>
|
||||
<SchemaInfo>
|
||||
|
||||
Vendored
+6
@@ -334,6 +334,12 @@
|
||||
],
|
||||
"url": "./schema/metadata/app/linkManager.json"
|
||||
},
|
||||
{
|
||||
"fileMatch": [
|
||||
"*/Resources/metadata/app/entityManager.json"
|
||||
],
|
||||
"url": "./schema/metadata/app/entityManager.json"
|
||||
},
|
||||
{
|
||||
"fileMatch": [
|
||||
"*/Resources/metadata/app/massActions.json"
|
||||
|
||||
@@ -39,10 +39,12 @@ use Espo\Core\Exceptions\BadRequest;
|
||||
use Espo\Core\Exceptions\Forbidden;
|
||||
use Espo\Tools\ExportCustom\ExportCustom;
|
||||
use Espo\Tools\ExportCustom\Params as ExportCustomParams;
|
||||
|
||||
use Espo\Tools\ExportCustom\Service as ExportCustomService;
|
||||
use Espo\Tools\LinkManager\LinkManager;
|
||||
use stdClass;
|
||||
|
||||
use const FILTER_SANITIZE_STRING;
|
||||
|
||||
class EntityManager
|
||||
{
|
||||
/**
|
||||
@@ -51,6 +53,7 @@ class EntityManager
|
||||
public function __construct(
|
||||
private User $user,
|
||||
private EntityManagerTool $entityManagerTool,
|
||||
private LinkManager $linkManager,
|
||||
private InjectableFactory $injectableFactory
|
||||
) {
|
||||
if (!$this->user->isAdmin()) {
|
||||
@@ -76,8 +79,8 @@ class EntityManager
|
||||
$name = $data['name'];
|
||||
$type = $data['type'];
|
||||
|
||||
$name = filter_var($name, \FILTER_SANITIZE_STRING);
|
||||
$type = filter_var($type, \FILTER_SANITIZE_STRING);
|
||||
$name = filter_var($name, FILTER_SANITIZE_STRING);
|
||||
$type = filter_var($type, FILTER_SANITIZE_STRING);
|
||||
|
||||
if (!is_string($name) || !is_string($type)) {
|
||||
throw new BadRequest();
|
||||
@@ -160,7 +163,7 @@ class EntityManager
|
||||
|
||||
$name = $data['name'];
|
||||
|
||||
$name = filter_var($name, \FILTER_SANITIZE_STRING);
|
||||
$name = filter_var($name, FILTER_SANITIZE_STRING);
|
||||
|
||||
if (!is_string($name)) {
|
||||
throw new BadRequest();
|
||||
@@ -188,7 +191,7 @@ class EntityManager
|
||||
|
||||
$name = $data['name'];
|
||||
|
||||
$name = filter_var($name, \FILTER_SANITIZE_STRING);
|
||||
$name = filter_var($name, FILTER_SANITIZE_STRING);
|
||||
|
||||
if (!is_string($name)) {
|
||||
throw new BadRequest();
|
||||
@@ -231,11 +234,11 @@ class EntityManager
|
||||
throw new BadRequest();
|
||||
}
|
||||
|
||||
$params[$item] = filter_var($data[$item], \FILTER_SANITIZE_STRING);
|
||||
$params[$item] = filter_var($data[$item], FILTER_SANITIZE_STRING);
|
||||
}
|
||||
|
||||
foreach ($additionalParamList as $item) {
|
||||
$params[$item] = filter_var($data[$item] ?? null, \FILTER_SANITIZE_STRING);
|
||||
$params[$item] = filter_var($data[$item] ?? null, FILTER_SANITIZE_STRING);
|
||||
}
|
||||
|
||||
$params['labelForeign'] = $params['labelForeign'] ?? $params['linkForeign'];
|
||||
@@ -290,7 +293,7 @@ class EntityManager
|
||||
* } $params
|
||||
*/
|
||||
|
||||
$this->entityManagerTool->createLink($params);
|
||||
$this->linkManager->create($params);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -318,7 +321,7 @@ class EntityManager
|
||||
|
||||
foreach ($paramList as $item) {
|
||||
if (array_key_exists($item, $data)) {
|
||||
$params[$item] = filter_var($data[$item], \FILTER_SANITIZE_STRING);
|
||||
$params[$item] = filter_var($data[$item], FILTER_SANITIZE_STRING);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -372,11 +375,15 @@ class EntityManager
|
||||
* } $params
|
||||
*/
|
||||
|
||||
$this->entityManagerTool->updateLink($params);
|
||||
$this->linkManager->update($params);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws BadRequest
|
||||
* @throws Error
|
||||
*/
|
||||
public function postActionRemoveLink(Request $request): bool
|
||||
{
|
||||
$data = $request->getParsedBody();
|
||||
@@ -391,7 +398,7 @@ class EntityManager
|
||||
$params = [];
|
||||
|
||||
foreach ($paramList as $item) {
|
||||
$params[$item] = filter_var($data[$item], \FILTER_SANITIZE_STRING);
|
||||
$params[$item] = filter_var($data[$item], FILTER_SANITIZE_STRING);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -401,7 +408,7 @@ class EntityManager
|
||||
* } $params
|
||||
*/
|
||||
|
||||
$this->entityManagerTool->deleteLink($params);
|
||||
$this->linkManager->delete($params);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -448,6 +455,10 @@ class EntityManager
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws BadRequest
|
||||
* @throws Error
|
||||
*/
|
||||
public function postActionResetToDefault(Request $request): bool
|
||||
{
|
||||
$data = $request->getParsedBody();
|
||||
|
||||
@@ -67,6 +67,11 @@ class Metadata
|
||||
['app', 'api', 'routeMiddlewareClassNameListMap', self::ANY_KEY],
|
||||
['app', 'api', 'controllerMiddlewareClassNameListMap', self::ANY_KEY],
|
||||
['app', 'api', 'controllerActionMiddlewareClassNameListMap', self::ANY_KEY],
|
||||
['app', 'entityManager', 'createHookClassNameList'],
|
||||
['app', 'entityManager', 'deleteHookClassNameList'],
|
||||
['app', 'entityManager', 'updateHookClassNameList'],
|
||||
['app', 'linkManager', 'createHookClassNameList'],
|
||||
['app', 'linkManager', 'deleteHookClassNameList'],
|
||||
['recordDefs', self::ANY_KEY, 'readLoaderClassNameList'],
|
||||
['recordDefs', self::ANY_KEY, 'listLoaderClassNameList'],
|
||||
['recordDefs', self::ANY_KEY, 'saverClassNameList'],
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"createHookClassNameList": [
|
||||
"Espo\\Tools\\EntityManager\\Hook\\Hooks\\PlusCreateHook"
|
||||
],
|
||||
"deleteHookClassNameList": [
|
||||
"Espo\\Tools\\EntityManager\\Hook\\Hooks\\PlusDeleteHook"
|
||||
],
|
||||
"updateHookClassNameList": []
|
||||
}
|
||||
@@ -1,10 +1,10 @@
|
||||
{
|
||||
"createHookClassNameList": [
|
||||
"Espo\\Tools\\EntityManager\\Link\\Hooks\\TargetListCreate",
|
||||
"Espo\\Tools\\EntityManager\\Link\\Hooks\\AssignedUsersCreate"
|
||||
"Espo\\Tools\\LinkManager\\Hook\\Hooks\\TargetListCreate",
|
||||
"Espo\\Tools\\LinkManager\\Hook\\Hooks\\AssignedUsersCreate"
|
||||
],
|
||||
"deleteHookClassNameList": [
|
||||
"Espo\\Tools\\EntityManager\\Link\\Hooks\\TargetListDelete",
|
||||
"Espo\\Tools\\EntityManager\\Link\\Hooks\\ForeignFieldDelete"
|
||||
"Espo\\Tools\\LinkManager\\Hook\\Hooks\\TargetListDelete",
|
||||
"Espo\\Tools\\LinkManager\\Hook\\Hooks\\ForeignFieldDelete"
|
||||
]
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
+6
-4
@@ -27,9 +27,11 @@
|
||||
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
|
||||
************************************************************************/
|
||||
|
||||
namespace Espo\Tools\EntityManager\Hooks;
|
||||
namespace Espo\Tools\EntityManager\Hook;
|
||||
|
||||
class CompanyType extends BasePlusType
|
||||
use Espo\Tools\EntityManager\Params;
|
||||
|
||||
interface CreateHook
|
||||
{
|
||||
|
||||
}
|
||||
public function process(Params $params): void;
|
||||
}
|
||||
+6
-4
@@ -27,9 +27,11 @@
|
||||
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
|
||||
************************************************************************/
|
||||
|
||||
namespace Espo\Tools\EntityManager\Hooks;
|
||||
namespace Espo\Tools\EntityManager\Hook;
|
||||
|
||||
class PersonType extends BasePlusType
|
||||
use Espo\Tools\EntityManager\Params;
|
||||
|
||||
interface DeleteHook
|
||||
{
|
||||
|
||||
}
|
||||
public function process(Params $params): void;
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
<?php
|
||||
/************************************************************************
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM - Open Source CRM application.
|
||||
* Copyright (C) 2014-2023 Yurii Kuznietsov, Taras Machyshyn, Oleksii Avramenko
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* EspoCRM is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* EspoCRM is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with EspoCRM. If not, see http://www.gnu.org/licenses/.
|
||||
*
|
||||
* 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 General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
|
||||
************************************************************************/
|
||||
|
||||
namespace Espo\Tools\EntityManager\Hook\Hooks;
|
||||
|
||||
use Espo\Core\Templates\Entities\BasePlus;
|
||||
use Espo\Core\Templates\Entities\Company;
|
||||
use Espo\Core\Templates\Entities\Person;
|
||||
use Espo\Core\Utils\Config;
|
||||
use Espo\Core\Utils\Metadata;
|
||||
use Espo\Modules\Crm\Entities\Task;
|
||||
use Espo\Tools\EntityManager\Hook\CreateHook;
|
||||
use Espo\Tools\EntityManager\Params;
|
||||
|
||||
class PlusCreateHook implements CreateHook
|
||||
{
|
||||
public function __construct(
|
||||
private Config $config,
|
||||
private Metadata $metadata
|
||||
) {}
|
||||
|
||||
public function process(Params $params): void
|
||||
{
|
||||
if (
|
||||
!in_array($params->getType(), [
|
||||
BasePlus::TEMPLATE_TYPE,
|
||||
Company::TEMPLATE_TYPE,
|
||||
Person::TEMPLATE_TYPE,
|
||||
])
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
$name = $params->getName();
|
||||
|
||||
$activitiesEntityTypeList = $this->config->get('activitiesEntityList', []);
|
||||
$historyEntityTypeList = $this->config->get('historyEntityList', []);
|
||||
|
||||
$entityTypeList = array_merge($activitiesEntityTypeList, $historyEntityTypeList);
|
||||
$entityTypeList[] = Task::ENTITY_TYPE;
|
||||
$entityTypeList = array_unique($entityTypeList);
|
||||
|
||||
foreach ($entityTypeList as $entityType) {
|
||||
if (!$this->metadata->get(['entityDefs', $entityType, 'fields', 'parent', 'entityList'])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$list = $this->metadata->get(['entityDefs', $entityType, 'fields', 'parent', 'entityList'], []);
|
||||
|
||||
if (!in_array($name, $list)) {
|
||||
$list[] = $name;
|
||||
|
||||
$data = [
|
||||
'fields' => [
|
||||
'parent' => ['entityList' => $list]
|
||||
]
|
||||
];
|
||||
|
||||
$this->metadata->set('entityDefs', $entityType, $data);
|
||||
}
|
||||
}
|
||||
|
||||
$this->metadata->save();
|
||||
}
|
||||
}
|
||||
+23
-38
@@ -27,53 +27,38 @@
|
||||
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
|
||||
************************************************************************/
|
||||
|
||||
namespace Espo\Tools\EntityManager\Hooks;
|
||||
namespace Espo\Tools\EntityManager\Hook\Hooks;
|
||||
|
||||
use Espo\Core\Di;
|
||||
use Espo\Core\Templates\Entities\BasePlus;
|
||||
use Espo\Core\Templates\Entities\Company;
|
||||
use Espo\Core\Templates\Entities\Person;
|
||||
use Espo\Core\Utils\Config;
|
||||
use Espo\Core\Utils\Metadata;
|
||||
use Espo\Modules\Crm\Entities\Task;
|
||||
use Espo\Tools\EntityManager\Hook\CreateHook;
|
||||
use Espo\Tools\EntityManager\Params;
|
||||
|
||||
class BasePlusType implements Di\ConfigAware, Di\MetadataAware
|
||||
class PlusDeleteHook implements CreateHook
|
||||
{
|
||||
use Di\ConfigSetter;
|
||||
use Di\MetadataSetter;
|
||||
public function __construct(
|
||||
private Config $config,
|
||||
private Metadata $metadata
|
||||
) {}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $params
|
||||
*/
|
||||
public function afterCreate(string $name, array $params): void
|
||||
public function process(Params $params): void
|
||||
{
|
||||
$activitiesEntityTypeList = $this->config->get('activitiesEntityList', []);
|
||||
$historyEntityTypeList = $this->config->get('historyEntityList', []);
|
||||
|
||||
$entityTypeList = array_merge($activitiesEntityTypeList, $historyEntityTypeList);
|
||||
$entityTypeList[] = Task::ENTITY_TYPE;
|
||||
$entityTypeList = array_unique($entityTypeList);
|
||||
|
||||
foreach ($entityTypeList as $entityType) {
|
||||
if (!$this->metadata->get(['entityDefs', $entityType, 'fields', 'parent', 'entityList'])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$list = $this->metadata->get(['entityDefs', $entityType, 'fields', 'parent', 'entityList'], []);
|
||||
|
||||
if (!in_array($name, $list)) {
|
||||
$list[] = $name;
|
||||
|
||||
$data = [
|
||||
'fields' => [
|
||||
'parent' => ['entityList' => $list]
|
||||
]
|
||||
];
|
||||
|
||||
$this->metadata->set('entityDefs', $entityType, $data);
|
||||
}
|
||||
if (
|
||||
!in_array($params->getType(), [
|
||||
BasePlus::TEMPLATE_TYPE,
|
||||
Company::TEMPLATE_TYPE,
|
||||
Person::TEMPLATE_TYPE,
|
||||
])
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->metadata->save();
|
||||
}
|
||||
$name = $params->getName();
|
||||
|
||||
public function afterRemove(string $name): void
|
||||
{
|
||||
$activitiesEntityTypeList = $this->config->get('activitiesEntityList', []);
|
||||
$historyEntityTypeList = $this->config->get('historyEntityList', []);
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
/************************************************************************
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM - Open Source CRM application.
|
||||
* Copyright (C) 2014-2023 Yurii Kuznietsov, Taras Machyshyn, Oleksii Avramenko
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* EspoCRM is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* EspoCRM is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with EspoCRM. If not, see http://www.gnu.org/licenses/.
|
||||
*
|
||||
* 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 General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
|
||||
************************************************************************/
|
||||
|
||||
namespace Espo\Tools\EntityManager\Hook;
|
||||
|
||||
use Espo\Tools\EntityManager\Params;
|
||||
|
||||
interface UpdateHook
|
||||
{
|
||||
public function process(Params $params, Params $previousParams): void;
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
/************************************************************************
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM - Open Source CRM application.
|
||||
* Copyright (C) 2014-2023 Yurii Kuznietsov, Taras Machyshyn, Oleksii Avramenko
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* EspoCRM is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* EspoCRM is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with EspoCRM. If not, see http://www.gnu.org/licenses/.
|
||||
*
|
||||
* 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 General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
|
||||
************************************************************************/
|
||||
|
||||
namespace Espo\Tools\EntityManager;
|
||||
|
||||
class Params
|
||||
{
|
||||
/**
|
||||
* @param array<string, mixed> $params
|
||||
*/
|
||||
public function __construct(
|
||||
private string $name,
|
||||
private ?string $type,
|
||||
private array $params
|
||||
) {}
|
||||
|
||||
public function get(string $name): mixed
|
||||
{
|
||||
return $this->params[$name] ?? null;
|
||||
}
|
||||
|
||||
public function getType(): ?string
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
public function getName(): string
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
}
|
||||
+3
-1
@@ -27,7 +27,9 @@
|
||||
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
|
||||
************************************************************************/
|
||||
|
||||
namespace Espo\Tools\EntityManager\Link;
|
||||
namespace Espo\Tools\LinkManager\Hook;
|
||||
|
||||
use Espo\Tools\LinkManager\Params;
|
||||
|
||||
interface CreateHook
|
||||
{
|
||||
+3
-1
@@ -27,7 +27,9 @@
|
||||
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
|
||||
************************************************************************/
|
||||
|
||||
namespace Espo\Tools\EntityManager\Link;
|
||||
namespace Espo\Tools\LinkManager\Hook;
|
||||
|
||||
use Espo\Tools\LinkManager\Params;
|
||||
|
||||
interface DeleteHook
|
||||
{
|
||||
+6
-10
@@ -27,22 +27,18 @@
|
||||
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
|
||||
************************************************************************/
|
||||
|
||||
namespace Espo\Tools\EntityManager\Link;
|
||||
namespace Espo\Tools\LinkManager\Hook;
|
||||
|
||||
use Espo\Core\Utils\Metadata;
|
||||
use Espo\Core\InjectableFactory;
|
||||
use Espo\Tools\LinkManager\Params;
|
||||
|
||||
class HookProcessor
|
||||
{
|
||||
private Metadata $metadata;
|
||||
|
||||
private InjectableFactory $injectableFactory;
|
||||
|
||||
public function __construct(Metadata $metadata, InjectableFactory $injectableFactory)
|
||||
{
|
||||
$this->metadata = $metadata;
|
||||
$this->injectableFactory = $injectableFactory;
|
||||
}
|
||||
public function __construct(
|
||||
private Metadata $metadata,
|
||||
private InjectableFactory $injectableFactory
|
||||
) {}
|
||||
|
||||
public function processCreate(Params $params): void
|
||||
{
|
||||
+6
-14
@@ -27,26 +27,20 @@
|
||||
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
|
||||
************************************************************************/
|
||||
|
||||
namespace Espo\Tools\EntityManager\Link\Hooks;
|
||||
|
||||
use Espo\Tools\EntityManager\Link\CreateHook;
|
||||
use Espo\Tools\EntityManager\Link\Params;
|
||||
use Espo\Tools\EntityManager\Link\Type;
|
||||
namespace Espo\Tools\LinkManager\Hook\Hooks;
|
||||
|
||||
use Espo\Tools\LinkManager\Hook\CreateHook;
|
||||
use Espo\Tools\LinkManager\Params;
|
||||
use Espo\Tools\LinkManager\Type;
|
||||
use Espo\Core\Utils\Metadata;
|
||||
|
||||
use Espo\Entities\User;
|
||||
|
||||
class AssignedUsersCreate implements CreateHook
|
||||
{
|
||||
private const LINK_NAME = 'assignedUsers';
|
||||
|
||||
private Metadata $metadata;
|
||||
|
||||
public function __construct(Metadata $metadata)
|
||||
{
|
||||
$this->metadata = $metadata;
|
||||
}
|
||||
public function __construct(private Metadata $metadata)
|
||||
{}
|
||||
|
||||
public function process(Params $params): void
|
||||
{
|
||||
@@ -75,8 +69,6 @@ class AssignedUsersCreate implements CreateHook
|
||||
$params->getLink() === self::LINK_NAME
|
||||
) {
|
||||
$this->processInternal($entityType);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
+7
-13
@@ -27,26 +27,20 @@
|
||||
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
|
||||
************************************************************************/
|
||||
|
||||
namespace Espo\Tools\EntityManager\Link\Hooks;
|
||||
|
||||
use Espo\Tools\EntityManager\Link\DeleteHook;
|
||||
use Espo\Tools\EntityManager\Link\Params;
|
||||
namespace Espo\Tools\LinkManager\Hook\Hooks;
|
||||
|
||||
use Espo\Tools\LinkManager\Hook\DeleteHook;
|
||||
use Espo\Tools\LinkManager\Params;
|
||||
use Espo\Core\Utils\Metadata;
|
||||
|
||||
use Espo\ORM\Defs;
|
||||
|
||||
class ForeignFieldDelete implements DeleteHook
|
||||
{
|
||||
private Metadata $metadata;
|
||||
|
||||
private Defs $defs;
|
||||
|
||||
public function __construct(Metadata $metadata, Defs $defs)
|
||||
{
|
||||
$this->metadata = $metadata;
|
||||
$this->defs = $defs;
|
||||
}
|
||||
public function __construct(
|
||||
private Metadata $metadata,
|
||||
private Defs $defs
|
||||
) {}
|
||||
|
||||
public function process(Params $params): void
|
||||
{
|
||||
+6
-11
@@ -27,25 +27,20 @@
|
||||
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
|
||||
************************************************************************/
|
||||
|
||||
namespace Espo\Tools\EntityManager\Link\Hooks;
|
||||
namespace Espo\Tools\LinkManager\Hook\Hooks;
|
||||
|
||||
use Espo\Core\Templates\Entities\Company;
|
||||
use Espo\Core\Templates\Entities\Person;
|
||||
use Espo\Tools\EntityManager\Link\CreateHook;
|
||||
use Espo\Tools\EntityManager\Link\Params;
|
||||
use Espo\Tools\EntityManager\Link\Type;
|
||||
use Espo\Tools\LinkManager\Hook\CreateHook;
|
||||
use Espo\Tools\LinkManager\Params;
|
||||
use Espo\Tools\LinkManager\Type;
|
||||
use Espo\Modules\Crm\Entities\TargetList;
|
||||
|
||||
use Espo\Core\Utils\Metadata;
|
||||
|
||||
class TargetListCreate implements CreateHook
|
||||
{
|
||||
private Metadata $metadata;
|
||||
|
||||
public function __construct(Metadata $metadata)
|
||||
{
|
||||
$this->metadata = $metadata;
|
||||
}
|
||||
public function __construct(private Metadata $metadata)
|
||||
{}
|
||||
|
||||
public function process(Params $params): void
|
||||
{
|
||||
+6
-10
@@ -27,25 +27,21 @@
|
||||
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
|
||||
************************************************************************/
|
||||
|
||||
namespace Espo\Tools\EntityManager\Link\Hooks;
|
||||
namespace Espo\Tools\LinkManager\Hook\Hooks;
|
||||
|
||||
use Espo\Core\Templates\Entities\Company;
|
||||
use Espo\Core\Templates\Entities\Person;
|
||||
use Espo\Tools\EntityManager\Link\DeleteHook;
|
||||
use Espo\Tools\EntityManager\Link\Params;
|
||||
use Espo\Tools\EntityManager\Link\Type;
|
||||
use Espo\Tools\LinkManager\Hook\DeleteHook;
|
||||
use Espo\Tools\LinkManager\Params;
|
||||
use Espo\Tools\LinkManager\Type;
|
||||
use Espo\Modules\Crm\Entities\TargetList;
|
||||
|
||||
use Espo\Core\Utils\Metadata;
|
||||
|
||||
class TargetListDelete implements DeleteHook
|
||||
{
|
||||
private Metadata $metadata;
|
||||
|
||||
public function __construct(Metadata $metadata)
|
||||
{
|
||||
$this->metadata = $metadata;
|
||||
}
|
||||
public function __construct(private Metadata $metadata)
|
||||
{}
|
||||
|
||||
public function process(Params $params): void
|
||||
{
|
||||
File diff suppressed because it is too large
Load Diff
+5
-3
@@ -27,7 +27,9 @@
|
||||
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
|
||||
************************************************************************/
|
||||
|
||||
namespace Espo\Tools\EntityManager\Link;
|
||||
namespace Espo\Tools\LinkManager;
|
||||
|
||||
use Espo\Tools\LinkManager\ParamsBuilder;
|
||||
|
||||
/**
|
||||
* @immutable
|
||||
@@ -38,8 +40,8 @@ class Params
|
||||
private string $entityType;
|
||||
private string $link;
|
||||
private string $foreignLink;
|
||||
private ?string $foreignEntityType = null;
|
||||
private ?string $name = null;
|
||||
private ?string $foreignEntityType;
|
||||
private ?string $name;
|
||||
|
||||
public function __construct(
|
||||
string $type,
|
||||
+1
-6
@@ -27,20 +27,15 @@
|
||||
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
|
||||
************************************************************************/
|
||||
|
||||
namespace Espo\Tools\EntityManager\Link;
|
||||
namespace Espo\Tools\LinkManager;
|
||||
|
||||
class ParamsBuilder
|
||||
{
|
||||
private string $type;
|
||||
|
||||
private string $entityType;
|
||||
|
||||
private string $link;
|
||||
|
||||
private string $foreignLink;
|
||||
|
||||
private ?string $foreignEntityType = null;
|
||||
|
||||
private ?string $name = null;
|
||||
|
||||
public function setType(string $type): self
|
||||
+1
-6
@@ -27,19 +27,14 @@
|
||||
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
|
||||
************************************************************************/
|
||||
|
||||
namespace Espo\Tools\EntityManager\Link;
|
||||
namespace Espo\Tools\LinkManager;
|
||||
|
||||
class Type
|
||||
{
|
||||
public const MANY_TO_MANY = 'manyToMany';
|
||||
|
||||
public const MANY_TO_ONE = 'manyToOne';
|
||||
|
||||
public const ONE_TO_MANY = 'oneToMany';
|
||||
|
||||
public const ONE_TO_ONE_LEFT = 'oneToOneLeft';
|
||||
|
||||
public const ONE_TO_ONE_RIGHT = 'oneToOneRight';
|
||||
|
||||
public const CHILDREN_TO_PARENT = 'childrenToParent';
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
{
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"$id": "https://www.espocrm.com/schema/metadata/app/entityManager.json",
|
||||
"title": "app/linkManager",
|
||||
"description": "Entity manager definitions.",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"createHookClassNameList": {
|
||||
"type": "array",
|
||||
"description": "Hooks called when creating a new entity (in the Entity Manager tool). Use __APPEND__ for extending. Should implement Espo\\Tools\\EntityManager\\Hook\\CreateHook.",
|
||||
"items": {
|
||||
"anyOf": [
|
||||
{"const": "__APPEND__"},
|
||||
{
|
||||
"type": "string"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"deleteHookClassNameList": {
|
||||
"type": "array",
|
||||
"description": "Hooks called when deleting an entity (in the Entity Manager tool). Use __APPEND__ for extending. Should implement Espo\\Tools\\EntityManager\\Hook\\DeleteHook.",
|
||||
"items": {
|
||||
"anyOf": [
|
||||
{"const": "__APPEND__"},
|
||||
{
|
||||
"type": "string"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"updateHookClassNameList": {
|
||||
"type": "array",
|
||||
"description": "Hooks called when updating an entity (in the Entity Manager tool). Use __APPEND__ for extending. Should implement Espo\\Tools\\EntityManager\\Hook\\UpdateHook.",
|
||||
"items": {
|
||||
"anyOf": [
|
||||
{"const": "__APPEND__"},
|
||||
{
|
||||
"type": "string"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,7 @@
|
||||
"properties": {
|
||||
"createHookClassNameList": {
|
||||
"type": "array",
|
||||
"description": "Hooks called when creating a new relationship (in the Entity Manager tool). Use __APPEND__ for extending. Should implement Espo\\Tools\\EntityManager\\Link\\CreateHook.",
|
||||
"description": "Hooks called when creating a new relationship (in the Entity Manager tool). Use __APPEND__ for extending. Should implement Espo\\Tools\\LinkManager\\Hook\\CreateHook.",
|
||||
"items": {
|
||||
"anyOf": [
|
||||
{"const": "__APPEND__"},
|
||||
@@ -19,7 +19,7 @@
|
||||
},
|
||||
"deleteHookClassNameList": {
|
||||
"type": "array",
|
||||
"description": "Hooks called when deleting a relationship (in the Entity Manager tool). Use __APPEND__ for extending. Should implement Espo\\Tools\\EntityManager\\Link\\DeleteHook.",
|
||||
"description": "Hooks called when deleting a relationship (in the Entity Manager tool). Use __APPEND__ for extending. Should implement Espo\\Tools\\LinkManager\\Hook\\DeleteHook.",
|
||||
"items": {
|
||||
"anyOf": [
|
||||
{"const": "__APPEND__"},
|
||||
|
||||
Reference in New Issue
Block a user