You are here

class MongodbConfigStorageBootstrap in MongoDB 8

Hierarchy

Expanded class hierarchy of MongodbConfigStorageBootstrap

1 file declares its use of MongodbConfigStorageBootstrap
settings.php in drivers/lib/Drupal/Driver/Database/mongodb/Install/settings.php

File

src/MongodbConfigStorageBootstrap.php, line 14
Definition of Drupal\mongodb\Config\ConfigStorageBootstrap.

Namespace

Drupal\mongodb
View source
class MongodbConfigStorageBootstrap extends MongodbConfigStorage {

  /**
   * TRUE if the storage was already read.
   *
   * The test runner causes the system to not read the module list, this
   * variable keeps track of that.
   *
   * @var bool
   */
  protected $read;

  /**
   * @var \Composer\Autoload\ClassLoader
   */
  protected $classLoader;
  public function __construct(MongoCollectionFactory $mongo, ClassLoader $class_loader) {
    parent::__construct($mongo);
    $this->classLoader = $class_loader;
  }

  /**
   * {@inheritdoc}
   */
  public function read($name) {
    if (!$this->read && $name != 'core.extension' && isset($GLOBALS['config']['core.extension']['module']['mongodb'])) {
      $debug = debug_backtrace();
      do {
        $current = array_pop($debug);
        if (isset($current['class']) && $current['class'] == 'Drupal\\Core\\Test\\TestRunnerKernel') {

          /** @var \Drupal\Core\Test\TestRunnerKernel $kernel */
          $kernel = $current['object'];
          $mongodb_path = substr(dirname(__DIR__), strlen($kernel
            ->getAppRoot()) + 1);
          $r = new \ReflectionObject($kernel);
          $service_providers = $r
            ->getProperty('serviceProviders');
          $service_providers
            ->setAccessible(TRUE);
          $value = $service_providers
            ->getValue($kernel);
          $value['app'][] = new MongodbServiceProvider();
          $service_providers
            ->setValue($kernel, $value);
          $services = $r
            ->getProperty('serviceYamls');
          $services
            ->setAccessible(TRUE);
          $value = $services
            ->getValue($kernel);
          $services_file = $mongodb_path . '/mongodb.services.yml';
          if (empty($value['app']) || !in_array($services_file, $value['app'])) {
            $value['app'][] = $services_file;
            foreach (array_keys($GLOBALS['config']['core.extension']['module']) as $module_name) {
              if (substr($module_name, 0, 8) == 'mongodb_') {
                $module_path = "{$mongodb_path}/{$module_name}";
                $filename = "{$module_path}/{$module_name}.services.yml";
                if (file_exists($filename)) {
                  $value['app'][] = $filename;
                  $this->classLoader
                    ->addPsr4('Drupal\\' . $module_name . '\\', DRUPAL_ROOT . "/{$module_path}/src");
                }
              }
            }
            $services
              ->setValue($kernel, $value);
          }
          break;
        }
      } while ($debug);
    }
    $this->read = TRUE;
    $result = parent::read($name);
    if ($name == 'core.extension' && isset($GLOBALS['config'][$name]['module'])) {
      if (!$result) {
        $result = array(
          'module' => array(),
        );
      }
      $read_module = $result['module'];
      $result['module'] += $GLOBALS['config'][$name]['module'];
      if (count($read_module) != count($result['module'])) {
        parent::write($name, $result);
      }
    }
    return $result;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
MongodbConfigStorage::$mongo protected property The object wrapping the MongoDB database object.
MongodbConfigStorage::$mongoCollectionName protected property The mongo collection name.
MongodbConfigStorage::$prefix protected property The prefix, typically 'config' or 'config.staging'.
MongodbConfigStorage::createCollection public function Creates a collection on the storage. Overrides StorageInterface::createCollection
MongodbConfigStorage::decode public function Decodes configuration data from the storage-specific format. Overrides StorageInterface::decode
MongodbConfigStorage::delete public function Deletes a configuration object from the storage. Overrides StorageInterface::delete
MongodbConfigStorage::deleteAll public function Deletes configuration objects whose names start with a given prefix. Overrides StorageInterface::deleteAll
MongodbConfigStorage::encode public function Encodes configuration data into the storage-specific format. Overrides StorageInterface::encode
MongodbConfigStorage::exists public function Returns whether a configuration object exists. Overrides StorageInterface::exists
MongodbConfigStorage::getAllCollectionNames public function Gets the existing collections. Overrides StorageInterface::getAllCollectionNames
MongodbConfigStorage::getCollectionName public function Gets the name of the current collection the storage is using. Overrides StorageInterface::getCollectionName
MongodbConfigStorage::listAll public function Gets configuration object names starting with a given prefix. Overrides StorageInterface::listAll
MongodbConfigStorage::mongoCollection protected function
MongodbConfigStorage::readMultiple public function Reads configuration data from the storage. Overrides StorageInterface::readMultiple
MongodbConfigStorage::rename public function Renames a configuration object in the storage. Overrides StorageInterface::rename
MongodbConfigStorage::write public function Writes configuration data to the storage. Overrides StorageInterface::write
MongodbConfigStorageBootstrap::$classLoader protected property
MongodbConfigStorageBootstrap::$read protected property TRUE if the storage was already read.
MongodbConfigStorageBootstrap::read public function Reads configuration data from the storage. Overrides MongodbConfigStorage::read
MongodbConfigStorageBootstrap::__construct public function Constructs a new ConfigStorage controller. Overrides MongodbConfigStorage::__construct
StorageInterface::DEFAULT_COLLECTION constant The default collection name.