decoupling
This commit is contained in:
+5
-8
@@ -27,14 +27,11 @@
|
||||
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
|
||||
************************************************************************/
|
||||
|
||||
namespace Espo\Core\Loaders;
|
||||
namespace Espo\Core\Di;
|
||||
|
||||
class EntityManagerHelper extends Base
|
||||
use Espo\Core\Utils\File\Manager as FileManager;
|
||||
|
||||
interface FileManagerAware
|
||||
{
|
||||
public function load()
|
||||
{
|
||||
return new \Espo\Core\ORM\Helper(
|
||||
$this->getContainer()->get('config')
|
||||
);
|
||||
}
|
||||
public function setFileManager(FileManager $fileManager);
|
||||
}
|
||||
+8
-6
@@ -27,14 +27,16 @@
|
||||
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
|
||||
************************************************************************/
|
||||
|
||||
namespace Espo\Core\Loaders;
|
||||
namespace Espo\Core\Di;
|
||||
|
||||
class WebSocketSubmission extends Base
|
||||
use Espo\Core\Utils\File\Manager as FileManager;
|
||||
|
||||
trait FileManagerSetter
|
||||
{
|
||||
public function load()
|
||||
protected $fileManager;
|
||||
|
||||
public function setFileManager(FileManager $fileManager)
|
||||
{
|
||||
return new \Espo\Core\WebSocket\Submission(
|
||||
$this->getContainer()->get('config')
|
||||
);
|
||||
$this->fileManager = $fileManager;
|
||||
}
|
||||
}
|
||||
@@ -33,21 +33,28 @@ use Espo\Core\Exceptions\Error;
|
||||
use Espo\Core\Exceptions\Forbidden;
|
||||
use Espo\Core\Exceptions\NotFound;
|
||||
|
||||
use Espo\Core\InjectableFactory;
|
||||
use Espo\Core\{
|
||||
ORM\EntityManager,
|
||||
Utils\Metadata,
|
||||
Utils\Config,
|
||||
InjectableFactory,
|
||||
};
|
||||
|
||||
class ClientManager
|
||||
{
|
||||
protected $entityManager;
|
||||
|
||||
protected $metadata;
|
||||
protected $config;
|
||||
protected $injectableFactory = null;
|
||||
|
||||
protected $clientMap = [];
|
||||
|
||||
protected $injectableFactory = null;
|
||||
|
||||
public function __construct(
|
||||
$entityManager, $metadata, $config, ?InjectableFactory $injectableFactory = null)
|
||||
{
|
||||
EntityManager $entityManager,
|
||||
Metadata $metadata,
|
||||
Config $config,
|
||||
?InjectableFactory $injectableFactory = null
|
||||
) {
|
||||
$this->entityManager = $entityManager;
|
||||
$this->metadata = $metadata;
|
||||
$this->config = $config;
|
||||
|
||||
@@ -33,6 +33,8 @@ use Espo\Core\Exceptions\Error;
|
||||
|
||||
use Espo\Core\InjectableFactory;
|
||||
|
||||
use Espo\Core\ORM\Entity;
|
||||
|
||||
class Evaluator
|
||||
{
|
||||
private $functionFactory = null;
|
||||
@@ -55,7 +57,7 @@ class Evaluator
|
||||
$this->parsedHash = [];
|
||||
}
|
||||
|
||||
public function process($expression, $entity = null, $variables = null)
|
||||
public function process(string $expression, ?Entity $entity = null, ?object $variables = null)
|
||||
{
|
||||
if (!array_key_exists($expression, $this->parsedHash)) {
|
||||
$item = $this->parser->parse($expression);
|
||||
|
||||
@@ -34,8 +34,13 @@ use Espo\Core\Exceptions\Error;
|
||||
use Espo\Core\InjectableFactory;
|
||||
use Espo\Core\Utils\Metadata;
|
||||
|
||||
use Espo\Core\ORM\Entity;
|
||||
|
||||
class Manager
|
||||
{
|
||||
protected $injectableFactory;
|
||||
protected $metadata;
|
||||
|
||||
public function __construct(InjectableFactory $injectableFactory, Metadata $metadata)
|
||||
{
|
||||
$functionClassNameMap = $metadata->get(['app', 'formula', 'functionClassNameMap'], []);
|
||||
@@ -43,7 +48,7 @@ class Manager
|
||||
$this->evaluator = new Evaluator($injectableFactory, $functionClassNameMap);
|
||||
}
|
||||
|
||||
public function run($script, $entity = null, $variables = null)
|
||||
public function run(string $script, ?Entity $entity = null, ?object $variables = null)
|
||||
{
|
||||
return $this->evaluator->process($script, $entity, $variables);
|
||||
}
|
||||
|
||||
@@ -36,6 +36,7 @@ use Espo\Core\{
|
||||
ORM\EntityManager as EntityManagerService,
|
||||
ORM\RepositoryFactory,
|
||||
ORM\EntityFactory,
|
||||
ORM\Helper,
|
||||
};
|
||||
|
||||
class EntityManager implements Loader
|
||||
@@ -59,6 +60,8 @@ class EntityManager implements Loader
|
||||
'entityFactory' => $entityFactory,
|
||||
]);
|
||||
|
||||
$helper = $this->injectableFactory->create(Helper::class);
|
||||
|
||||
$config = $this->config;
|
||||
|
||||
$params = [
|
||||
@@ -82,6 +85,7 @@ class EntityManager implements Loader
|
||||
'params' => $params,
|
||||
'repositoryFactory' => $repositoryFactory,
|
||||
'entityFactory' => $entityFactory,
|
||||
'helper' => $helper,
|
||||
]);
|
||||
|
||||
return $entityManager;
|
||||
|
||||
@@ -1,42 +0,0 @@
|
||||
<?php
|
||||
/************************************************************************
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM - Open Source CRM application.
|
||||
* Copyright (C) 2014-2020 Yuri Kuznetsov, Taras Machyshyn, Oleksiy 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\Core\Loaders;
|
||||
|
||||
class ExternalAccountClientManager extends Base
|
||||
{
|
||||
public function load()
|
||||
{
|
||||
return new \Espo\Core\ExternalAccount\ClientManager(
|
||||
$this->getContainer()->get('entityManager'),
|
||||
$this->getContainer()->get('metadata'),
|
||||
$this->getContainer()->get('config')
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
<?php
|
||||
/************************************************************************
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM - Open Source CRM application.
|
||||
* Copyright (C) 2014-2020 Yuri Kuznetsov, Taras Machyshyn, Oleksiy 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\Core\Loaders;
|
||||
|
||||
class FormulaManager extends Base
|
||||
{
|
||||
public function load()
|
||||
{
|
||||
$formulaManager = new \Espo\Core\Formula\Manager(
|
||||
$this->getContainer()->get('injectableFactory'),
|
||||
$this->getContainer()->get('metadata')
|
||||
);
|
||||
|
||||
return $formulaManager;
|
||||
}
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
<?php
|
||||
/************************************************************************
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM - Open Source CRM application.
|
||||
* Copyright (C) 2014-2020 Yuri Kuznetsov, Taras Machyshyn, Oleksiy 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\Core\Loaders;
|
||||
|
||||
class PasswordHash extends Base
|
||||
{
|
||||
public function load()
|
||||
{
|
||||
return new \Espo\Core\Utils\PasswordHash(
|
||||
$this->getContainer()->get('config')
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
<?php
|
||||
/************************************************************************
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM - Open Source CRM application.
|
||||
* Copyright (C) 2014-2020 Yuri Kuznetsov, Taras Machyshyn, Oleksiy 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\Core\Loaders;
|
||||
|
||||
class SelectManagerFactory extends Base
|
||||
{
|
||||
public function load()
|
||||
{
|
||||
return new \Espo\Core\SelectManagerFactory(
|
||||
$this->getContainer()->get('entityManager'),
|
||||
$this->getContainer()->get('user'),
|
||||
$this->getContainer()->get('acl'),
|
||||
$this->getContainer()->get('aclManager'),
|
||||
$this->getContainer()->get('metadata'),
|
||||
$this->getContainer()->get('config'),
|
||||
$this->getContainer()->get('fieldManagerUtil'),
|
||||
$this->getContainer()->get('injectableFactory'),
|
||||
$this->getContainer()->get('classFinder')
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
<?php
|
||||
/************************************************************************
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM - Open Source CRM application.
|
||||
* Copyright (C) 2014-2020 Yuri Kuznetsov, Taras Machyshyn, Oleksiy 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\Core\Loaders;
|
||||
|
||||
class ServiceFactory extends Base
|
||||
{
|
||||
public function load()
|
||||
{
|
||||
return new \Espo\Core\ServiceFactory(
|
||||
$this->getContainer()->get('classFinder'),
|
||||
$this->getContainer()->get('injectableFactory')
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
<?php
|
||||
/************************************************************************
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM - Open Source CRM application.
|
||||
* Copyright (C) 2014-2020 Yuri Kuznetsov, Taras Machyshyn, Oleksiy 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\Core\Loaders;
|
||||
|
||||
class TemplateFileManager extends Base
|
||||
{
|
||||
public function load()
|
||||
{
|
||||
$templateFileManager = new \Espo\Core\Utils\TemplateFileManager(
|
||||
$this->getContainer()->get('config'),
|
||||
$this->getContainer()->get('metadata'),
|
||||
$this->getContainer()->get('fileManager')
|
||||
);
|
||||
|
||||
return $templateFileManager;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,43 +0,0 @@
|
||||
<?php
|
||||
/************************************************************************
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM - Open Source CRM application.
|
||||
* Copyright (C) 2014-2020 Yuri Kuznetsov, Taras Machyshyn, Oleksiy 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\Core\Loaders;
|
||||
|
||||
class WebhookManager extends Base
|
||||
{
|
||||
public function load()
|
||||
{
|
||||
return new \Espo\Core\Webhook\Manager(
|
||||
$this->getContainer()->get('config'),
|
||||
$this->getContainer()->get('fileManager'),
|
||||
$this->getContainer()->get('entityManager'),
|
||||
$this->getContainer()->get('fieldManagerUtil')
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -54,12 +54,12 @@ class EntityManager extends BaseEntityManager
|
||||
RepositoryFactory $repositoryFactory,
|
||||
EntityFactory $entityFactory,
|
||||
HookManager $hookManager,
|
||||
Helper $entityManagerHelper
|
||||
Helper $helper
|
||||
) {
|
||||
parent::__construct($params, $repositoryFactory, $entityFactory);
|
||||
|
||||
$this->hookManager = $hookManager;
|
||||
$this->helper = $entityManagerHelper;
|
||||
$this->helper = $helper;
|
||||
}
|
||||
|
||||
// TODO Check whether setUser is needed here
|
||||
|
||||
@@ -33,6 +33,7 @@ use \Espo\Core\Interfaces\Injectable;
|
||||
|
||||
use \Espo\ORM\EntityFactory;
|
||||
|
||||
/** Deprecated */
|
||||
abstract class Repository extends \Espo\ORM\Repository implements Injectable
|
||||
{
|
||||
protected $dependencyList = [];
|
||||
|
||||
@@ -40,20 +40,14 @@ use Espo\Core\Utils\Util;
|
||||
class SelectManagerFactory
|
||||
{
|
||||
private $entityManager;
|
||||
|
||||
private $user;
|
||||
|
||||
private $acl;
|
||||
|
||||
private $metadata;
|
||||
|
||||
private $injectableFactory;
|
||||
|
||||
private $fieldManagerUtil;
|
||||
|
||||
private $classFinder;
|
||||
|
||||
protected $baseClassName = '\\Espo\\Core\\SelectManager';
|
||||
protected $baseClassName = SelectManager::class;
|
||||
|
||||
public function __construct(
|
||||
EntityManager $entityManager,
|
||||
@@ -64,8 +58,8 @@ class SelectManagerFactory
|
||||
Utils\Config $config,
|
||||
Utils\FieldManagerUtil $fieldManagerUtil,
|
||||
InjectableFactory $injectableFactory,
|
||||
Utils\ClassFinder $classFinder)
|
||||
{
|
||||
Utils\ClassFinder $classFinder
|
||||
) {
|
||||
$this->entityManager = $entityManager;
|
||||
$this->user = $user;
|
||||
$this->acl = $acl;
|
||||
|
||||
@@ -146,4 +146,3 @@ class TemplateFileManager
|
||||
return $fileName;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ class Manager
|
||||
protected $config;
|
||||
protected $fileManager;
|
||||
protected $entityManager;
|
||||
protected $fieldManager;
|
||||
protected $fieldManagerUtil;
|
||||
|
||||
private $cacheFile = 'data/cache/application/webhooks.php';
|
||||
|
||||
@@ -54,12 +54,12 @@ class Manager
|
||||
Config $config,
|
||||
FileManager $fileManager,
|
||||
EntityManager $entityManager,
|
||||
FieldManagerUtil $fieldManager
|
||||
FieldManagerUtil $fieldManagerUtil
|
||||
) {
|
||||
$this->config = $config;
|
||||
$this->fileManager = $fileManager;
|
||||
$this->entityManager = $entityManager;
|
||||
$this->fieldManager = $fieldManager;
|
||||
$this->fieldManagerUtil = $fieldManagerUtil;
|
||||
|
||||
$this->loadData();
|
||||
}
|
||||
@@ -202,11 +202,11 @@ class Manager
|
||||
$this->logDebugEvent($event, $entity);
|
||||
}
|
||||
|
||||
foreach ($this->fieldManager->getEntityTypeFieldList($entity->getEntityType()) as $field) {
|
||||
foreach ($this->fieldManagerUtil->getEntityTypeFieldList($entity->getEntityType()) as $field) {
|
||||
$itemEvent = $entity->getEntityType() . '.fieldUpdate.' . $field;
|
||||
if (!$this->eventExists($itemEvent)) continue;
|
||||
|
||||
$attributeList = $this->fieldManager->getActualAttributeList($entity->getEntityType(), $field);
|
||||
$attributeList = $this->fieldManagerUtil->getActualAttributeList($entity->getEntityType(), $field);
|
||||
$isChanged = false;
|
||||
foreach ($attributeList as $attribute) {
|
||||
if (in_array($attribute, $this->skipAttributeList)) continue;
|
||||
@@ -219,7 +219,7 @@ class Manager
|
||||
if ($isChanged) {
|
||||
$itemData = (object) [];
|
||||
$itemData->id = $entity->id;
|
||||
$attributeList = $this->fieldManager->getAttributeList($entity->getEntityType(), $field);
|
||||
$attributeList = $this->fieldManagerUtil->getAttributeList($entity->getEntityType(), $field);
|
||||
foreach ($attributeList as $attribute) {
|
||||
if (in_array($attribute, $this->skipAttributeList)) continue;
|
||||
$itemData->$attribute = $entity->get($attribute);
|
||||
|
||||
@@ -35,7 +35,6 @@ use Espo\ORM\EntityCollection;
|
||||
use Espo\ORM\Entity;
|
||||
use Espo\ORM\IEntity;
|
||||
|
||||
|
||||
class RDB extends \Espo\ORM\Repository
|
||||
{
|
||||
/**
|
||||
@@ -110,7 +109,7 @@ class RDB extends \Espo\ORM\Repository
|
||||
}
|
||||
}
|
||||
|
||||
public function getById($id, array $params = []) : ?Entity
|
||||
public function getById(string $id, array $params = []) : ?Entity
|
||||
{
|
||||
$entity = $this->entityFactory->create($this->entityType);
|
||||
if (!$entity) return null;
|
||||
@@ -122,7 +121,7 @@ class RDB extends \Espo\ORM\Repository
|
||||
return $this->getMapper()->selectById($entity, $id, $params);
|
||||
}
|
||||
|
||||
public function get($id = null) : ?Entity
|
||||
public function get(?string $id = null) : ?Entity
|
||||
{
|
||||
if (is_null($id)) {
|
||||
return $this->getNew();
|
||||
@@ -170,7 +169,7 @@ class RDB extends \Espo\ORM\Repository
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function restoreDeleted($id)
|
||||
public function restoreDeleted(string $id)
|
||||
{
|
||||
return $this->getMapper()->restoreDeleted($this->entityType, $id);
|
||||
}
|
||||
@@ -193,7 +192,7 @@ class RDB extends \Espo\ORM\Repository
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function deleteFromDb($id, $onlyDeleted = false)
|
||||
public function deleteFromDb(string $id, bool $onlyDeleted = false)
|
||||
{
|
||||
return $this->getMapper()->deleteFromDb($this->entityType, $id, $onlyDeleted);
|
||||
}
|
||||
@@ -282,7 +281,7 @@ class RDB extends \Espo\ORM\Repository
|
||||
}
|
||||
}
|
||||
|
||||
public function countRelated(Entity $entity, $relationName, array $params = [])
|
||||
public function countRelated(Entity $entity, string $relationName, array $params = [])
|
||||
{
|
||||
if (!$entity->id) {
|
||||
return;
|
||||
@@ -295,7 +294,7 @@ class RDB extends \Espo\ORM\Repository
|
||||
return intval($this->getMapper()->countRelated($entity, $relationName, $params));
|
||||
}
|
||||
|
||||
public function isRelated(Entity $entity, $relationName, $foreign)
|
||||
public function isRelated(Entity $entity, string $relationName, $foreign)
|
||||
{
|
||||
if (!$entity->id) {
|
||||
return null;
|
||||
@@ -342,7 +341,7 @@ class RDB extends \Espo\ORM\Repository
|
||||
]);
|
||||
}
|
||||
|
||||
public function relate(Entity $entity, $relationName, $foreign, $data = null, array $options = [])
|
||||
public function relate(Entity $entity, string $relationName, $foreign, $data = null, array $options = [])
|
||||
{
|
||||
if (!$entity->id) {
|
||||
return;
|
||||
@@ -383,7 +382,7 @@ class RDB extends \Espo\ORM\Repository
|
||||
}
|
||||
|
||||
|
||||
public function unrelate(Entity $entity, $relationName, $foreign, array $options = [])
|
||||
public function unrelate(Entity $entity, string $relationName, $foreign, array $options = [])
|
||||
{
|
||||
if (!$entity->id) {
|
||||
return;
|
||||
@@ -451,7 +450,7 @@ class RDB extends \Espo\ORM\Repository
|
||||
{
|
||||
}
|
||||
|
||||
public function updateRelation(Entity $entity, $relationName, $foreign, $data)
|
||||
public function updateRelation(Entity $entity, string $relationName, $foreign, $data)
|
||||
{
|
||||
if (!$entity->id) {
|
||||
return;
|
||||
@@ -470,7 +469,7 @@ class RDB extends \Espo\ORM\Repository
|
||||
return null;
|
||||
}
|
||||
|
||||
public function massRelate(Entity $entity, $relationName, array $params = [], array $options = [])
|
||||
public function massRelate(Entity $entity, string $relationName, array $params = [], array $options = [])
|
||||
{
|
||||
if (!$entity->id) {
|
||||
return;
|
||||
|
||||
@@ -81,7 +81,7 @@ abstract class Repository
|
||||
return $this->entityType;
|
||||
}
|
||||
|
||||
abstract public function get($id = null);
|
||||
abstract public function get(?string $id = null);
|
||||
|
||||
abstract public function save(Entity $entity);
|
||||
|
||||
|
||||
@@ -30,53 +30,63 @@
|
||||
namespace Espo\Repositories;
|
||||
|
||||
use Espo\ORM\Entity;
|
||||
use Espo\ORM\Repository;
|
||||
use Espo\Core\Utils\Json;
|
||||
|
||||
class Preferences extends \Espo\Core\ORM\Repository
|
||||
use Espo\Core\Di\{
|
||||
FileManagerAware,
|
||||
FileManagerSetter,
|
||||
MetadataAware,
|
||||
MetadataSetter,
|
||||
ConfigAware,
|
||||
ConfigSetter,
|
||||
EntityManagerAware,
|
||||
EntityManagerSetter,
|
||||
};
|
||||
|
||||
class Preferences extends Repository implements
|
||||
FileManagerAware,
|
||||
MetadataAware,
|
||||
ConfigAware,
|
||||
EntityManagerAware
|
||||
{
|
||||
use FileManagerSetter;
|
||||
use MetadataSetter;
|
||||
use ConfigSetter;
|
||||
use EntityManagerSetter;
|
||||
|
||||
protected $defaultAttributeListFromSettings = [
|
||||
'decimalMark',
|
||||
'thousandSeparator',
|
||||
'exportDelimiter',
|
||||
'followCreatedEntities'
|
||||
'followCreatedEntities',
|
||||
];
|
||||
|
||||
protected $data = array();
|
||||
protected $data = [];
|
||||
|
||||
protected $entityType = 'Preferences';
|
||||
|
||||
protected function init()
|
||||
{
|
||||
parent::init();
|
||||
$this->addDependencyList([
|
||||
'fileManager',
|
||||
'metadata',
|
||||
'config',
|
||||
'entityManager'
|
||||
]);
|
||||
}
|
||||
|
||||
protected function getFileManager()
|
||||
{
|
||||
return $this->getInjection('fileManager');
|
||||
return $this->fileManager;
|
||||
}
|
||||
|
||||
protected function getEntityManger()
|
||||
{
|
||||
return $this->getInjection('entityManager');
|
||||
return $this->entityManager;
|
||||
}
|
||||
|
||||
protected function getMetadata()
|
||||
{
|
||||
return $this->getInjection('metadata');
|
||||
return $this->metadata;
|
||||
}
|
||||
|
||||
protected function getConfig()
|
||||
{
|
||||
return $this->getInjection('config');
|
||||
return $this->config;
|
||||
}
|
||||
|
||||
public function get($id = null)
|
||||
public function get(?string $id = null)
|
||||
{
|
||||
if ($id) {
|
||||
$entity = $this->entityFactory->create('Preferences');
|
||||
@@ -236,7 +246,7 @@ class Preferences extends \Espo\Core\ORM\Repository
|
||||
$ps = $pdo->query($sql);
|
||||
}
|
||||
|
||||
public function remove(Entity $entity, array $options = array())
|
||||
public function remove(Entity $entity, array $options = [])
|
||||
{
|
||||
if (!$entity->id) return;
|
||||
$this->deleteFromDb($entity->id);
|
||||
|
||||
@@ -20,15 +20,33 @@
|
||||
"cronManager": {
|
||||
"className": "Espo\\Core\\CronManager"
|
||||
},
|
||||
"webSocketSubmission": {
|
||||
"className": "Espo\\Core\\WebSocket\\Submission"
|
||||
},
|
||||
"crypt": {
|
||||
"className": "Espo\\Core\\Utils\\Crypt"
|
||||
},
|
||||
"passwordHash": {
|
||||
"className": "Espo\\Core\\Utils\\PasswordHash"
|
||||
},
|
||||
"number": {
|
||||
"loaderClassName": "Espo\\Core\\Loaders\\NumberUtil"
|
||||
},
|
||||
"controllerManager": {
|
||||
"className": "Espo\\Core\\ControllerManager"
|
||||
},
|
||||
"selectManagerFactory": {
|
||||
"className": "Espo\\Core\\SelectManagerFactory"
|
||||
},
|
||||
"serviceFactory": {
|
||||
"className": "Espo\\Core\\ServiceFactory"
|
||||
},
|
||||
"templateFileManager": {
|
||||
"className": "Espo\\Core\\Utils\\TemplateFileManager"
|
||||
},
|
||||
"webhookManager": {
|
||||
"className": "Espo\\Core\\Webhook\\Manager"
|
||||
},
|
||||
"scheduledJob": {
|
||||
"className": "Espo\\Core\\Utils\\ScheduledJob"
|
||||
},
|
||||
@@ -83,6 +101,12 @@
|
||||
"entityManagerUtil": {
|
||||
"className": "Espo\\Core\\Utils\\EntityManager"
|
||||
},
|
||||
"externalAccountClientManager": {
|
||||
"className": "Espo\\Core\\ExternalAccount\\ClientManager"
|
||||
},
|
||||
"formulaManager": {
|
||||
"className": "Espo\\Core\\Formula\\Manager"
|
||||
},
|
||||
"user": {
|
||||
"settable": true
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user