/**
  * {@inheritdoc}
  */
 public function getAclResources()
 {
     $aclResourceConfig = $this->_configReader->read();
     if (!empty($aclResourceConfig['config']['acl']['resources'])) {
         return $this->_resourceTreeBuilder->build($aclResourceConfig['config']['acl']['resources']);
     }
     return [];
 }
Exemple #2
0
 /**
  * {@inheritdoc}
  */
 public function getAclResources()
 {
     // TODO: As soon as all acl.xml files are moved to global scope, default ('global') scope should be used
     $aclResourceConfig = $this->_configReader->read('adminhtml');
     if (!empty($aclResourceConfig['config']['acl']['resources'])) {
         return $this->_resourceTreeBuilder->build($aclResourceConfig['config']['acl']['resources']);
     }
     return array();
 }
Exemple #3
0
 /**
  * Constructor
  *
  * @param \Magento\Framework\Config\ReaderInterface $reader
  * @param \Magento\Framework\Config\CacheInterface $cache
  * @param string $cacheId
  */
 public function __construct(\Magento\Framework\Config\ReaderInterface $reader, \Magento\Framework\Config\CacheInterface $cache, $cacheId)
 {
     $data = $cache->load($cacheId);
     if (false === $data) {
         $data = $reader->read();
         $cache->save(serialize($data), $cacheId);
     } else {
         $data = unserialize($data);
     }
     $this->merge($data);
 }
Exemple #4
0
 public function testGet()
 {
     $data = ['a' => 'b'];
     $cacheid = 'test';
     $this->cache->expects($this->once())->method('load')->will($this->returnValue(false));
     $this->reader->expects($this->once())->method('read')->will($this->returnValue($data));
     $config = new \Magento\Framework\Config\Data($this->reader, $this->cache, $cacheid);
     $this->assertEquals($data, $config->get());
     $this->assertEquals('b', $config->get('a'));
     $this->assertEquals(null, $config->get('a/b'));
     $this->assertEquals(33, $config->get('a/b', 33));
 }
Exemple #5
0
 /**
  * Load data for current scope
  *
  * @return void
  */
 protected function _loadScopedData()
 {
     $scope = $this->_configScope->getCurrentScope();
     if (false == isset($this->_loadedScopes[$scope])) {
         if (false == in_array($scope, $this->_scopePriorityScheme)) {
             $this->_scopePriorityScheme[] = $scope;
         }
         foreach ($this->_scopePriorityScheme as $scopeCode) {
             if (false == isset($this->_loadedScopes[$scopeCode])) {
                 if ($scopeCode !== 'primary' && ($data = $this->_cache->load($scopeCode . '::' . $this->_cacheId))) {
                     $data = unserialize($data);
                 } else {
                     $data = $this->_reader->read($scopeCode);
                     if ($scopeCode !== 'primary') {
                         $this->_cache->save(serialize($data), $scopeCode . '::' . $this->_cacheId);
                     }
                 }
                 $this->merge($data);
                 $this->_loadedScopes[$scopeCode] = true;
             }
             if ($scopeCode == $scope) {
                 break;
             }
         }
     }
 }
Exemple #6
0
 /**
  * @param \Magento\Framework\Config\ReaderInterface $reader
  * @param \Magento\Framework\Config\ScopeListInterface $scopeList
  * @param \Magento\Framework\Cache\FrontendInterface $cache
  * @param \Magento\Framework\ObjectManager\Relations $relations
  * @param \Magento\Framework\Interception\ObjectManager\Config $omConfig
  * @param \Magento\Framework\ObjectManager\Definition $classDefinitions
  * @param string $cacheId
  */
 public function __construct(\Magento\Framework\Config\ReaderInterface $reader, \Magento\Framework\Config\ScopeListInterface $scopeList, \Magento\Framework\Cache\FrontendInterface $cache, \Magento\Framework\ObjectManager\Relations $relations, \Magento\Framework\Interception\ObjectManager\Config $omConfig, \Magento\Framework\ObjectManager\Definition $classDefinitions, $cacheId = 'interception')
 {
     $this->_omConfig = $omConfig;
     $this->_relations = $relations;
     $this->_classDefinitions = $classDefinitions;
     $this->_cache = $cache;
     $this->_cacheId = $cacheId;
     $this->_reader = $reader;
     $intercepted = $this->_cache->load($this->_cacheId);
     if ($intercepted !== false) {
         $this->_intercepted = unserialize($intercepted);
     } else {
         $config = array();
         foreach ($scopeList->getAllScopes() as $scope) {
             $config = array_replace_recursive($config, $this->_reader->read($scope));
         }
         unset($config['preferences']);
         foreach ($config as $typeName => $typeConfig) {
             if (!empty($typeConfig['plugins'])) {
                 $this->_intercepted[ltrim($typeName, '\\')] = true;
             }
         }
         foreach ($config as $typeName => $typeConfig) {
             $this->hasPlugins(ltrim($typeName, '\\'));
         }
         foreach ($classDefinitions->getClasses() as $class) {
             $this->hasPlugins($class);
         }
         $this->_cache->save(serialize($this->_intercepted), $this->_cacheId);
     }
 }
Exemple #7
0
 /**
  * Initialize interception config
  *
  * @param array $classDefinitions
  * @return void
  */
 public function initialize($classDefinitions = [])
 {
     $this->_cache->clean(\Zend_Cache::CLEANING_MODE_MATCHING_TAG, [$this->_cacheId]);
     $config = [];
     foreach ($this->_scopeList->getAllScopes() as $scope) {
         $config = array_replace_recursive($config, $this->_reader->read($scope));
     }
     unset($config['preferences']);
     foreach ($config as $typeName => $typeConfig) {
         if (!empty($typeConfig['plugins'])) {
             $this->_intercepted[ltrim($typeName, '\\')] = true;
         }
     }
     foreach ($config as $typeName => $typeConfig) {
         $this->hasPlugins($typeName);
     }
     foreach ($classDefinitions as $class) {
         $this->hasPlugins($class);
     }
     $this->_cache->save(serialize($this->_intercepted), $this->_cacheId);
 }