Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Builder.php
Go to the documentation of this file.
1 <?php
6 namespace Magento\Framework\Acl;
7 
16 class Builder
17 {
23  protected $_acl;
24 
30  protected $_loaderPool;
31 
35  protected $_aclFactory;
36 
43  public function __construct(
44  \Magento\Framework\AclFactory $aclFactory,
45  \Magento\Framework\Acl\LoaderInterface $roleLoader,
46  \Magento\Framework\Acl\LoaderInterface $resourceLoader,
47  \Magento\Framework\Acl\LoaderInterface $ruleLoader
48  ) {
49  $this->_aclFactory = $aclFactory;
50  $this->_loaderPool = [$roleLoader, $resourceLoader, $ruleLoader];
51  }
52 
59  public function getAcl()
60  {
61  if ($this->_acl instanceof \Magento\Framework\Acl) {
62  return $this->_acl;
63  }
64 
65  try {
66  $this->_acl = $this->_aclFactory->create();
67  foreach ($this->_loaderPool as $loader) {
68  $loader->populateAcl($this->_acl);
69  }
70  } catch (\Exception $e) {
71  throw new \LogicException('Could not create an acl object: ' . $e->getMessage());
72  }
73 
74  return $this->_acl;
75  }
76 
83  public function resetRuntimeAcl()
84  {
85  $this->_acl = null;
86  return $this;
87  }
88 }
$loader
Definition: autoload.php:8
__construct(\Magento\Framework\AclFactory $aclFactory, \Magento\Framework\Acl\LoaderInterface $roleLoader, \Magento\Framework\Acl\LoaderInterface $resourceLoader, \Magento\Framework\Acl\LoaderInterface $ruleLoader)
Definition: Builder.php:43