Skip to content

EspoCRM – Open Source CRM Application

order applier acl manager

Yuri Kuznetsov2ce99b370264
diff --git a/application/Espo/Core/Select/Applier/Factory.php b/application/Espo/Core/Select/Applier/Factory.php
index b1253b6f16..513ffdb4f4 100644
--- a/application/Espo/Core/Select/Applier/Factory.php
+++ b/application/Espo/Core/Select/Applier/Factory.php
@@ -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)
diff --git a/tests/unit/Espo/Core/Select/Applier/FactoryTest.php b/tests/unit/Espo/Core/Select/Applier/FactoryTest.php
index 7c40fc5e24..1135d27029 100644
--- a/tests/unit/Espo/Core/Select/Applier/FactoryTest.php
+++ b/tests/unit/Espo/Core/Select/Applier/FactoryTest.php
@@ -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);