installCollectionDefaultConfig example

public function installOptionalConfig(?\Drupal\Core\Config\StorageInterface $storage = NULL, $dependency = array (
        ))
        {
            return $this->lazyLoadItself()->installOptionalConfig($storage$dependency);
        }

        /** * {@inheritdoc} */
        public function installCollectionDefaultConfig($collection)
        {
            return $this->lazyLoadItself()->installCollectionDefaultConfig($collection);
        }

        /** * {@inheritdoc} */
        public function setSourceStorage(\Drupal\Core\Config\StorageInterface $storage)
        {
            return $this->lazyLoadItself()->setSourceStorage($storage);
        }

        /** * {@inheritdoc} */
public function setLanguage(LanguageInterface $language = NULL) {
    $this->language = $language;
    return $this;
  }

  /** * {@inheritdoc} */
  public function installLanguageOverrides($langcode) {
    /** @var \Drupal\Core\Config\ConfigInstallerInterface $config_installer */
    $config_installer = \Drupal::service('config.installer');
    $config_installer->installCollectionDefaultConfig($this->createConfigCollectionName($langcode));
  }

  /** * {@inheritdoc} */
  public function createConfigObject($name$collection = StorageInterface::DEFAULT_COLLECTION) {
    $langcode = $this->getLangcodeFromCollectionName($collection);
    return $this->getOverride($langcode$name);
  }

  /** * {@inheritdoc} */
$this->fail('Expected PreExistingConfigException not thrown.');
    }
    catch (PreExistingConfigException $e) {
      $this->assertEquals('config_collection_clash_install_test', $e->getExtension());
      $this->assertEquals(['another_collection' => ['config_collection_install_test.test'], 'collection.test1' => ['config_collection_install_test.test'], 'collection.test2' => ['config_collection_install_test.test']]$e->getConfigObjects());
      $this->assertEquals('Configuration objects (another_collection/config_collection_install_test.test, collection/test1/config_collection_install_test.test, collection/test2/config_collection_install_test.test) provided by config_collection_clash_install_test already exist in active configuration', $e->getMessage());
    }

    // Test that the we can use the config installer to install all the     // available default configuration in a particular collection for enabled     // extensions.     \Drupal::service('config.installer')->installCollectionDefaultConfig('entity');
    // The 'entity' collection will not exist because the 'config_test' module     // is not enabled.     $this->assertEquals($collections$active_storage->getAllCollectionNames());
    // Enable the 'config_test' module and try again.     $this->enableModules(['config_test']);
    \Drupal::service('config.installer')->installCollectionDefaultConfig('entity');
    $collections[] = 'entity';
    $this->assertEquals($collections$active_storage->getAllCollectionNames());
    $collection_storage = $active_storage->createCollection('entity');
    $data = $collection_storage->read('config_test.dynamic.dotted.default');
    $this->assertSame(['label' => 'entity']$data);

    
Home | Imprint | This part of the site doesn't use cookies.