acl refactoring

This commit is contained in:
Yuri Kuznetsov
2021-04-19 15:29:30 +03:00
parent 30813f5efc
commit bb947ac0a9
21 changed files with 84 additions and 24 deletions

View File

@@ -27,7 +27,12 @@
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
namespace Espo\Core\Acl;
namespace Espo\Core\Acl\AccessChecker;
use Espo\Core\{
Acl\ScopeData,
Acl\Table,
};
/**
* Checks scope access.

View File

@@ -27,7 +27,7 @@
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
namespace Espo\Core\Acl;
namespace Espo\Core\Acl\AccessChecker;
/**
* Scope checker data.

View File

@@ -27,7 +27,7 @@
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
namespace Espo\Core\Acl;
namespace Espo\Core\Acl\AccessChecker;
/**
* Builds scope checker data.

View File

@@ -37,6 +37,8 @@ use Espo\Entities\User;
use Espo\Core\{
ORM\EntityManager,
Acl\AccessChecker\ScopeCheckerData,
Acl\AccessChecker\ScopeChecker,
AclManager,
Utils\Config,
};

View File

@@ -35,6 +35,8 @@ use Espo\ORM\Entity;
use Espo\Core\{
Acl\Table,
Acl\AccessChecker\ScopeCheckerData,
Acl\AccessChecker\ScopeChecker,
AclManager,
Utils\Config,
Utils\DateTime as DateTimeUtil,

View File

@@ -27,12 +27,14 @@
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
namespace Espo\Core\Acl;
namespace Espo\Core\Acl\Table;
use Espo\Entities\User;
use Espo\Core\{
InjectableFactory,
Acl\Table,
Acl\DefaultTable,
Acl\Table\CacheKeyProvider,
Acl\Table\DefaultCacheKeyProvider,
Acl\Table\RoleListProvider,
@@ -42,7 +44,7 @@ use Espo\Core\{
Binding\BindingData,
};
class TableFactory
class DefaultTableFactory implements TableFactory
{
private $injectableFactory;
@@ -53,8 +55,6 @@ class TableFactory
/**
* Create a table.
*
* @todo Use binding.
*/
public function create(User $user): Table
{

View File

@@ -0,0 +1,42 @@
<?php
/************************************************************************
* This file is part of EspoCRM.
*
* EspoCRM - Open Source CRM application.
* Copyright (C) 2014-2021 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\Core\Acl\Table;
use Espo\Entities\User;
use Espo\Core\Acl\Table;
interface TableFactory
{
/**
* Create a table.
*/
public function create(User $user): Table;
}

View File

@@ -38,7 +38,7 @@ use Espo\Core\{
Acl,
Acl\GlobalRestricton,
Acl\OwnerUserFieldProvider,
Acl\TableFactory,
Acl\Table\TableFactory,
Acl\Table,
Acl\Map\Map,
Acl\Map\MapFactory,

View File

@@ -42,8 +42,8 @@ use Espo\Core\{
Acl\AccessChecker,
Acl\ScopeData,
Portal\Acl\Table,
Portal\Acl\ScopeChecker,
Portal\Acl\ScopeCheckerData,
Portal\Acl\AccessChecker\ScopeChecker,
Portal\Acl\AccessChecker\ScopeCheckerData,
Portal\Acl\DefaultAccessChecker,
};

View File

@@ -192,5 +192,10 @@ class DefaultBinding implements BindingProcessor
'Espo\\Core\\WebSocket\\Subscriber',
'Espo\\Core\\WebSocket\\ZeroMQSubscriber'
);
$binder->bindImplementation(
'Espo\\Core\\Acl\\Table\\TableFactory',
'Espo\\Core\\Acl\\Table\\DefaultTableFactory'
);
}
}

View File

@@ -27,7 +27,7 @@
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
namespace Espo\Core\Portal\Acl;
namespace Espo\Core\Portal\Acl\AccessChecker;
use Espo\Core\{
Acl\ScopeData,

View File

@@ -27,7 +27,7 @@
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
namespace Espo\Core\Portal\Acl;
namespace Espo\Core\Portal\Acl\AccessChecker;
/**
* Scope checker data.

View File

@@ -27,7 +27,7 @@
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
namespace Espo\Core\Portal\Acl;
namespace Espo\Core\Portal\Acl\AccessChecker;
/**
* Builds scope checker data.

View File

@@ -36,6 +36,8 @@ use Espo\ORM\Entity;
use Espo\Core\{
Utils\Config,
Portal\AclManager as PortalAclManager,
Portal\Acl\AccessChecker\ScopeChecker,
Portal\Acl\AccessChecker\ScopeCheckerData,
Acl\ScopeData,
Acl\AccessEntityCreateChecker,
Acl\AccessEntityReadChecker,

View File

@@ -27,7 +27,7 @@
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
namespace Espo\Core\Portal\Acl;
namespace Espo\Core\Portal\Acl\Table;
use Espo\Entities\{
User,
@@ -37,6 +37,7 @@ use Espo\Entities\{
use Espo\Core\{
InjectableFactory,
Acl\Table\CacheKeyProvider,
Portal\Acl\Table,
Portal\Acl\Table\CacheKeyProvider as PortalCacheKeyProvider,
Acl\Table\RoleListProvider,
Portal\Acl\Table\RoleListProvider as PortalRoleListProvider,

View File

@@ -40,12 +40,12 @@ use Espo\Entities\{
};
use Espo\Core\{
Portal\Acl\Table as Table,
Portal\Acl\Table,
Portal\Acl\Table\TableFactory,
Portal\Acl\AccessCheckerFactory,
Portal\Acl\OwnershipCheckerFactory,
Portal\Acl\OwnershipAccountChecker,
Portal\Acl\OwnershipContactChecker,
Portal\Acl\TableFactory,
Portal\Acl,
Portal\Acl\Map\MapFactory,
Acl\GlobalRestricton,

View File

@@ -30,7 +30,7 @@
namespace tests\unit\Espo\Core\Acl;
use Espo\Core\{
Acl\ScopeCheckerData,
Acl\AccessChecker\ScopeCheckerData,
};
class ScopeCheckerDataTest extends \PHPUnit\Framework\TestCase

View File

@@ -30,8 +30,8 @@
namespace tests\unit\Espo\Core\Acl;
use Espo\Core\{
Acl\ScopeChecker,
Acl\ScopeCheckerData,
Acl\AccessChecker\ScopeChecker,
Acl\AccessChecker\ScopeCheckerData,
Acl\ScopeData,
Acl\Table,
};

View File

@@ -35,7 +35,7 @@ use Espo\Core\{
Acl\AccessCheckerFactory,
Acl\OwnershipCheckerFactory,
Acl\OwnerUserFieldProvider,
Acl\TableFactory,
Acl\Table\TableFactory,
Acl\GlobalRestricton,
Acl\Map\MapFactory,
ORM\EntityManager,

View File

@@ -30,12 +30,13 @@
namespace tests\unit\Espo\Core\Portal\Acl;
use Espo\Core\{
Portal\Acl\ScopeCheckerData,
Portal\Acl\AccessChecker\ScopeCheckerData,
};
class ScopeCheckerDataTest extends \PHPUnit\Framework\TestCase
{
protected function setUp() : void
protected function setUp(): void
{
}

View File

@@ -30,8 +30,8 @@
namespace tests\unit\Espo\Core\Portal\Acl;
use Espo\Core\{
Portal\Acl\ScopeChecker,
Portal\Acl\ScopeCheckerData,
Portal\Acl\AccessChecker\ScopeChecker,
Portal\Acl\AccessChecker\ScopeCheckerData,
Portal\Acl\Table,
Acl\ScopeData,
};