FeaturesExtensionStorages.php in Features 8.3        
                          
                  
                        
  
  
  
  
File
  src/FeaturesExtensionStorages.php
  
    View source  
  <?php
namespace Drupal\features;
use Drupal\Core\Config\InstallStorage;
use Drupal\Core\Config\StorageInterface;
use Drupal\Core\Extension\Extension;
class FeaturesExtensionStorages implements FeaturesExtensionStoragesInterface {
  
  protected $configStorage;
  
  protected $extensionStorages;
  
  protected $configurationLists;
  
  public function __construct(StorageInterface $config_storage) {
    $this->configStorage = $config_storage;
  }
  
  public function getExtensionStorages() {
    return $this->extensionStorages;
  }
  
  public function addStorage($directory = InstallStorage::CONFIG_INSTALL_DIRECTORY) {
    $this->extensionStorages[$directory] = new FeaturesInstallStorage($this->configStorage, $directory);
    $this
      ->reset();
  }
  
  public function read($name) {
    $list = $this
      ->listAllByDirectory('');
    if (isset($list[$name])) {
      $directory = $list[$name];
      return $this->extensionStorages[$directory]
        ->read($name);
    }
    return FALSE;
  }
  
  public function listAll($prefix = '') {
    return array_keys($this
      ->listAllByDirectory($prefix));
  }
  
  public function listExtensionConfig(Extension $extension) {
    $extension_config = [];
    foreach ($this->extensionStorages as $directory => $extension_storage) {
      $extension_config = array_merge($extension_config, array_keys($extension_storage
        ->getComponentNames([
        $extension
          ->getName() => $extension,
      ])));
    }
    return $extension_config;
  }
  
  protected function reset() {
    $this->configurationLists = [];
  }
  
  protected function listAllByDirectory($prefix = '') {
    if (!isset($this->configurationLists[$prefix])) {
      $this->configurationLists[$prefix] = [];
      foreach ($this->extensionStorages as $directory => $extension_storage) {
        $this->configurationLists[$prefix] += array_fill_keys($extension_storage
          ->listAll($prefix), $directory);
      }
    }
    return $this->configurationLists[$prefix];
  }
}