order applier acl manager

This commit is contained in:
Yuri Kuznetsov
2025-03-19 15:11:36 +02:00
parent 8008741e35
commit 2ce99b3702
2 changed files with 23 additions and 2 deletions
@@ -29,6 +29,7 @@
namespace Espo\Core\Select\Applier;
use Espo\Core\AclManager;
use Espo\Core\Select\Text\Applier as TextFilterApplier;
use Espo\Core\Select\AccessControl\Applier as AccessControlFilterApplier;
use Espo\Core\Select\Where\Applier as WhereApplier;
@@ -45,6 +46,7 @@ use Espo\Core\InjectableFactory;
use Espo\Core\Select\SelectManager;
use Espo\Core\Select\SelectManagerFactory;
use Espo\Core\Utils\Acl\UserAclManagerProvider;
use Espo\Entities\User;
use RuntimeException;
@@ -77,6 +79,7 @@ class Factory
public function __construct(
private InjectableFactory $injectableFactory,
private UserAclManagerProvider $userAclManagerProvider,
private SelectManagerFactory $selectManagerFactory
) {}
@@ -87,11 +90,14 @@ class Factory
// SelectManager is used for backward compatibility.
$selectManager = $this->selectManagerFactory->create($entityType, $user);
$aclManager = $this->userAclManagerProvider->get($user);
$bindingData = new BindingData();
$binder = new Binder($bindingData);
$binder
->bindInstance(User::class, $user)
->bindInstance(AclManager::class, $aclManager)
->bindInstance(SelectManager::class, $selectManager)
->for($className)
->bindValue('$entityType', $entityType)
@@ -29,6 +29,7 @@
namespace tests\unit\Espo\Core\Select\Applier;
use Espo\Core\AclManager;
use Espo\Core\Binding\Binder;
use Espo\Core\Binding\BindingContainer;
use Espo\Core\Binding\BindingData;
@@ -46,21 +47,34 @@ use Espo\Core\Select\SelectManagerFactory;
use Espo\Core\Select\Text\Applier as TextFilterApplier;
use Espo\Core\Select\Where\Applier as WhereApplier;
use Espo\Core\Utils\Acl\UserAclManagerProvider;
use Espo\Entities\User;
use PHPUnit\Framework\TestCase;
class FactoryTest extends \PHPUnit\Framework\TestCase
class FactoryTest extends TestCase
{
private $aclManager;
protected function setUp(): void
{
$this->injectableFactory = $this->createMock(InjectableFactory::class);
$this->selectManagerFactory = $this->createMock(SelectManagerFactory::class);
$this->selectManagerFactory = $this->createMock(SelectManagerFactory::class);
$this->user = $this->createMock(User::class);
$this->selectManager = $this->createMock(SelectManager::class);
$userAclManagerProvider = $this->createMock(UserAclManagerProvider::class);
$this->aclManager = $this->createMock(AclManager::class);
$userAclManagerProvider
->expects($this->any())
->method('get')
->willReturn($this->aclManager);
$this->factory = new ApplierFactory(
$this->injectableFactory,
$userAclManagerProvider,
$this->selectManagerFactory
);
}
@@ -134,6 +148,7 @@ class FactoryTest extends \PHPUnit\Framework\TestCase
$binder
->bindInstance(User::class, $this->user)
->bindInstance(SelectManager::class, $this->selectManager)
->bindInstance(AclManager::class, $this->aclManager)
->for($applierClassName)
->bindValue('$entityType', $entityType)
->bindValue('$selectManager', $this->selectManager);