EspoCRM – Open Source CRM Application
PHP calendarcontactscrmcrm-platformcrm-systemcustomer-portalcustomer-supportcustomizabledocumentsemail-marketingkanbanleadsopen-sourcephpplatformsales-automationsingle-page-applicationsupport
Base record controller removal
Yurii77ba672d1a05
diff --git a/application/Espo/Controllers/Import.php b/application/Espo/Controllers/Import.phpindex f012b41880..7934ef9bbe 100644--- a/application/Espo/Controllers/Import.php+++ b/application/Espo/Controllers/Import.php@@ -29,29 +29,14 @@namespace Espo\Controllers;-use Espo\Core\Exceptions\BadRequest;-use Espo\Core\Exceptions\Error;use Espo\Core\Exceptions\Forbidden;--use Espo\Core\Exceptions\NotFound;-use Espo\Tools\Import\Params as ImportParams;-use Espo\Tools\Import\Service as Service;-use Espo\Core\Api\Request;use Espo\Core\Api\Response;use Espo\Core\Controllers\Record;--use Espo\Core\Di\InjectableFactoryAware;-use Espo\Core\Di\InjectableFactorySetter;-use stdClass;class Import extends Record-- implements InjectableFactoryAware{- use InjectableFactorySetter;-protected function checkAccess(): bool{return $this->acl->check('Import');diff --git a/application/Espo/Core/Controllers/Base.php b/application/Espo/Core/Controllers/Base.phpdeleted file mode 100644index fd5162a34d..0000000000--- a/application/Espo/Core/Controllers/Base.php+++ /dev/null@@ -1,153 +0,0 @@-<?php-/************************************************************************- * This file is part of EspoCRM.- *- * EspoCRM – Open Source CRM application.- * Copyright (C) 2014-2026 EspoCRM, Inc.- * Website: https://www.espocrm.com- *- * This program is free software: you can redistribute it and/or modify- * it under the terms of the GNU Affero General Public License as published by- * the Free Software Foundation, either version 3 of the License, or- * (at your option) any later version.- *- * This program 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 Affero General Public License for more details.- *- * You should have received a copy of the GNU Affero General Public License- * along with this program. If not, see <https://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 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\Controllers;--use Espo\Core\Acl;-use Espo\Core\AclManager;-use Espo\Core\Exceptions\Forbidden;-use Espo\Core\Utils\Config;-use Espo\Core\Utils\Metadata;--use Espo\Entities\Preferences;-use Espo\Entities\User;--/**- * @deprecated Don't extend.- * @todo Remove in v10.0.- */-abstract class Base-{- /**- * @var string- */- protected $name;-- /**- * @var string- */- public static $defaultAction = 'index';--- /**- * @var User- */- protected $user;-- /**- * @var Acl- */- protected $acl;-- /**- * @deprecated- * @var AclManager- */- protected $aclManager;-- /**- * @var Config- */- protected $config;-- /**- * @deprecated- * @var Preferences- */- protected $preferences;-- /**- * @deprecated- * @var Metadata- */- protected $metadata;-- /**- * @throws Forbidden- * @internal Most dependencies are for backward compatibility.- */- public function __construct(- User $user,- Acl $acl,- AclManager $aclManager,- Config $config,- Preferences $preferences,- Metadata $metadata,- ) {- $this->user = $user;- $this->acl = $acl;- $this->aclManager = $aclManager;- $this->config = $config;- $this->preferences = $preferences;- $this->metadata = $metadata;-- if (empty($this->name)) {- $name = get_class($this);-- $matches = null;-- if (preg_match('@\\\\([\w]+)$@', $name, $matches)) {- $name = $matches[1];- }-- $this->name = $name;- }-- $this->checkControllerAccess();-- if (!$this->checkAccess()) {- throw new Forbidden("No access to '{$this->name}'.");- }- }-- /**- * @deprecated- */- protected function getName(): string- {- /** @var string */- return $this->name;- }-- /**- * Check access to controller.- */- protected function checkAccess(): bool- {- return true;- }-- /**- * @return void- * @deprecated- */- protected function checkControllerAccess()- {- }-}diff --git a/application/Espo/Core/Controllers/RecordBase.php b/application/Espo/Core/Controllers/RecordBase.phpindex d79be6be30..cbdb28f565 100644--- a/application/Espo/Core/Controllers/RecordBase.php+++ b/application/Espo/Core/Controllers/RecordBase.php@@ -36,6 +36,7 @@ use Espo\Core\Exceptions\BadRequest;use Espo\Core\Exceptions\ForbiddenSilent;use Espo\Core\Exceptions\NotFound;use Espo\Core\Exceptions\NotFoundSilent;+use Espo\Core\InjectableFactory;use Espo\Core\Record\ServiceContainer as RecordServiceContainer;use Espo\Core\Record\SearchParamsFetcher;use Espo\Core\Record\CreateParamsFetcher;@@ -44,78 +45,67 @@ use Espo\Core\Record\UpdateParamsFetcher;use Espo\Core\Record\DeleteParamsFetcher;use Espo\Core\Record\FindParamsFetcher;use Espo\Core\Record\Service as RecordService;-use Espo\Core\Container;use Espo\Core\Acl;-use Espo\Core\AclManager;use Espo\Core\Utils\Config;-use Espo\Core\Utils\Metadata;-use Espo\Core\ServiceFactory;use Espo\Core\Api\Request;use Espo\Core\Api\Response;use Espo\Core\Select\SearchParams;-use Espo\Core\Di;use Espo\Entities\User;-use Espo\Entities\Preferences;use Espo\ORM\Entity;-use Espo\ORM\EntityManager;-use stdClass;-class RecordBase extends Base implements-- Di\EntityManagerAware,- Di\InjectableFactoryAware+class RecordBase{- use Di\EntityManagerSetter;- use Di\InjectableFactorySetter;++ /**+ * @internal+ */+ protected string $name;+/** @var string */public static $defaultAction = 'list';- /** @var RecordServiceContainer */- protected $recordServiceContainer;- /** @var Config */- protected $config;- /** @var User */- protected $user;- /** @var Acl */- protected $acl;-/**- * @deprecated- * @var EntityManager+ * @throws Forbidden*/- protected $entityManager;-public function __construct(protected SearchParamsFetcher $searchParamsFetcher,protected CreateParamsFetcher $createParamsFetcher,protected ReadParamsFetcher $readParamsFetcher,protected UpdateParamsFetcher $updateParamsFetcher,protected DeleteParamsFetcher $deleteParamsFetcher,- RecordServiceContainer $recordServiceContainer,+ protected RecordServiceContainer $recordServiceContainer,protected FindParamsFetcher $findParamsFetcher,- Config $config,- User $user,- Acl $acl,- // Parameters below are for backward compatibility.- AclManager $aclManager,- Preferences $preferences,- Metadata $metadata,+ protected Config $config,+ protected User $user,+ protected Acl $acl,+ protected InjectableFactory $injectableFactory,) {- $this->recordServiceContainer = $recordServiceContainer;- $this->config = $config;- $this->user = $user;- $this->acl = $acl;-- parent::__construct(- $user,- $acl,- $aclManager,- $config,- $preferences,- $metadata,- );++ if (empty($this->name)) {+ $name = get_class($this);++ $matches = null;++ if (preg_match('@\\\\([\w]+)$@', $name, $matches)) {+ $name = $matches[1];+ }++ $this->name = $name;+ }++ if (!$this->checkAccess()) {+ throw new Forbidden("No access to '$this->name'.");+ }+ }++ /**+ * Check access to controller.+ */+ protected function checkAccess(): bool+ {+ return true;}protected function getEntityType(): stringdiff --git a/application/Espo/Modules/Crm/Controllers/CaseObj.php b/application/Espo/Modules/Crm/Controllers/CaseObj.phpindex df84f8d0f6..646bb3fcaf 100644--- a/application/Espo/Modules/Crm/Controllers/CaseObj.php+++ b/application/Espo/Modules/Crm/Controllers/CaseObj.php@@ -40,7 +40,7 @@ use stdClass;class CaseObj extends Record{- protected $name = CaseEntity::ENTITY_TYPE;+ protected string $name = CaseEntity::ENTITY_TYPE;/*** @return stdClass[]