Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Protected Attributes
Builder Class Reference

Public Member Functions

 __construct (\Magento\Framework\AclFactory $aclFactory, \Magento\Framework\Acl\LoaderInterface $roleLoader, \Magento\Framework\Acl\LoaderInterface $resourceLoader, \Magento\Framework\Acl\LoaderInterface $ruleLoader)
 
 getAcl ()
 
 resetRuntimeAcl ()
 

Protected Attributes

 $_acl
 
 $_loaderPool
 
 $_aclFactory
 

Detailed Description

Access Control List Builder. Retrieves required role/rule/resource loaders and uses them to populate provided ACL object. Acl object is put to cache after creation. On consequent requests, ACL object is deserialized from cache.

@api

Since
100.0.2

Definition at line 16 of file Builder.php.

Constructor & Destructor Documentation

◆ __construct()

Parameters
\Magento\Framework\AclFactory$aclFactory
\Magento\Framework\Acl\LoaderInterface$roleLoader
\Magento\Framework\Acl\LoaderInterface$resourceLoader
\Magento\Framework\Acl\LoaderInterface$ruleLoader

Definition at line 43 of file Builder.php.

48  {
49  $this->_aclFactory = $aclFactory;
50  $this->_loaderPool = [$roleLoader, $resourceLoader, $ruleLoader];
51  }

Member Function Documentation

◆ getAcl()

getAcl ( )

Build Access Control List

Returns
\Magento\Framework\Acl
Exceptions

Definition at line 59 of file Builder.php.

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  }
$loader
Definition: autoload.php:8

◆ resetRuntimeAcl()

resetRuntimeAcl ( )

Remove cached ACL instance.

Returns
$this
Since
101.0.0

Definition at line 83 of file Builder.php.

84  {
85  $this->_acl = null;
86  return $this;
87  }

Field Documentation

◆ $_acl

$_acl
protected

Definition at line 23 of file Builder.php.

◆ $_aclFactory

$_aclFactory
protected

Definition at line 35 of file Builder.php.

◆ $_loaderPool

$_loaderPool
protected

Definition at line 30 of file Builder.php.


The documentation for this class was generated from the following file: