/**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     $this->info = array('type' => 'profile', 'core' => \Drupal::CORE_COMPATIBILITY, 'name' => 'Distribution profile', 'distribution' => array('name' => 'My Distribution', 'langcode' => $this->langcode, 'install' => array('theme' => 'bartik')));
     // File API functions are not available yet.
     $path = $this->siteDirectory . '/profiles/mydistro';
     mkdir($path, 0777, TRUE);
     file_put_contents("{$path}/mydistro.info.yml", Yaml::encode($this->info));
     parent::setUp();
 }
 protected function setUp()
 {
     $this->info = array('type' => 'profile', 'core' => \Drupal::CORE_COMPATIBILITY, 'name' => 'Override standard', 'hidden' => TRUE);
     // File API functions are not available yet.
     $path = $this->siteDirectory . '/profiles/standard';
     mkdir($path, 0777, TRUE);
     file_put_contents("{$path}/standard.info.yml", Yaml::encode($this->info));
     parent::setUp();
 }
 protected function setUp()
 {
     // Copy the testing_config_overrides install profile so we can change the
     // configuration to include a dependency that can not be met. File API
     // functions are not available yet.
     $dest = $this->siteDirectory . '/profiles/testing_config_overrides';
     mkdir($dest, 0777, TRUE);
     $source = DRUPAL_ROOT . '/core/profiles/testing_config_overrides';
     $iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($source, \RecursiveDirectoryIterator::SKIP_DOTS), \RecursiveIteratorIterator::SELF_FIRST);
     foreach ($iterator as $item) {
         if ($item->isDir()) {
             mkdir($dest . DIRECTORY_SEPARATOR . $iterator->getSubPathName());
         } else {
             copy($item, $dest . DIRECTORY_SEPARATOR . $iterator->getSubPathName());
         }
     }
     // Add a dependency that can not be met because User is installed before
     // Action.
     $config_file = $dest . DIRECTORY_SEPARATOR . InstallStorage::CONFIG_INSTALL_DIRECTORY . DIRECTORY_SEPARATOR . 'system.action.user_block_user_action.yml';
     $action = Yaml::decode(file_get_contents($config_file));
     $action['dependencies']['module'][] = 'action';
     file_put_contents($config_file, Yaml::encode($action));
     parent::setUp();
 }
Beispiel #4
0
 /**
  * Changes parameters in the services.yml file.
  *
  * @param string $name
  *   The name of the parameter.
  * @param mixed $value
  *   The value of the parameter.
  */
 protected function setContainerParameter($name, $value)
 {
     $filename = $this->siteDirectory . '/services.yml';
     chmod($filename, 0666);
     $services = Yaml::decode(file_get_contents($filename));
     $services['parameters'][$name] = $value;
     file_put_contents($filename, Yaml::encode($services));
     // Ensure that the cache is deleted for the yaml file loader.
     $file_cache = FileCacheFactory::get('container_yaml_loader');
     $file_cache->delete($filename);
 }
 /**
  * Handles switching the export textarea.
  */
 public function updateExport($form, FormStateInterface $form_state)
 {
     // Determine the full config name for the selected config entity.
     if ($form_state->getValue('config_type') !== 'system.simple') {
         $definition = $this->entityManager->getDefinition($form_state->getValue('config_type'));
         $name = $definition->getConfigPrefix() . '.' . $form_state->getValue('config_name');
     } else {
         $name = $form_state->getValue('config_name');
     }
     // Read the raw data for this config name, encode it, and display it.
     $form['export']['#value'] = Yaml::encode($this->configStorage->read($name));
     $form['export']['#description'] = $this->t('Filename: %name', array('%name' => $name . '.yml'));
     return $form['export'];
 }
 /**
  * Tests importing a simple configuration file.
  */
 public function testImportSimpleConfiguration()
 {
     $this->drupalLogin($this->drupalCreateUser(array('import configuration')));
     $config = $this->config('system.site')->set('name', 'Test simple import');
     // Place branding block with site name into header region.
     $this->drupalPlaceBlock('system_branding_block', ['region' => 'header']);
     $edit = array('config_type' => 'system.simple', 'config_name' => $config->getName(), 'import' => Yaml::encode($config->get()));
     $this->drupalPostForm('admin/config/development/configuration/single/import', $edit, t('Import'));
     $this->assertRaw(t('Are you sure you want to update the %name @type?', array('%name' => $config->getName(), '@type' => 'simple configuration')));
     $this->drupalPostForm(NULL, array(), t('Confirm'));
     $this->drupalGet('');
     $this->assertText('Test simple import');
     // Ensure that ConfigImporter validation is running when importing simple
     // configuration.
     $config_data = $this->config('core.extension')->get();
     // Simulate uninstalling the Config module.
     unset($config_data['module']['config']);
     $edit = array('config_type' => 'system.simple', 'config_name' => 'core.extension', 'import' => Yaml::encode($config_data));
     $this->drupalPostForm('admin/config/development/configuration/single/import', $edit, t('Import'));
     $this->assertText(t('Can not uninstall the Configuration module as part of a configuration synchronization through the user interface.'));
 }
Beispiel #7
0
 /**
  * {@inheritdoc}
  */
 public function diff(StorageInterface $source_storage, StorageInterface $target_storage, $source_name, $target_name = NULL, $collection = StorageInterface::DEFAULT_COLLECTION)
 {
     if ($collection != StorageInterface::DEFAULT_COLLECTION) {
         $source_storage = $source_storage->createCollection($collection);
         $target_storage = $target_storage->createCollection($collection);
     }
     if (!isset($target_name)) {
         $target_name = $source_name;
     }
     // The output should show configuration object differences formatted as YAML.
     // But the configuration is not necessarily stored in files. Therefore, they
     // need to be read and parsed, and lastly, dumped into YAML strings.
     $source_data = explode("\n", Yaml::encode($source_storage->read($source_name)));
     $target_data = explode("\n", Yaml::encode($target_storage->read($target_name)));
     // Check for new or removed files.
     if ($source_data === array('false')) {
         // Added file.
         // Cast the result of t() to a string, as the diff engine doesn't know
         // about objects.
         $source_data = array((string) $this->t('File added'));
     }
     if ($target_data === array('false')) {
         // Deleted file.
         // Cast the result of t() to a string, as the diff engine doesn't know
         // about objects.
         $target_data = array((string) $this->t('File removed'));
     }
     return new Diff($source_data, $target_data);
 }
Beispiel #8
0
 /**
  * {@inheritdoc}
  */
 public function encode($data)
 {
     return Yaml::encode($data);
 }
 /**
  * Downloads a tarball of the site configuration.
  */
 public function downloadExport()
 {
     file_unmanaged_delete(file_directory_temp() . '/config.tar.gz');
     $archiver = new ArchiveTar(file_directory_temp() . '/config.tar.gz', 'gz');
     // Get raw configuration data without overrides.
     foreach ($this->configManager->getConfigFactory()->listAll() as $name) {
         $archiver->addString("{$name}.yml", Yaml::encode($this->configManager->getConfigFactory()->get($name)->getRawData()));
     }
     // Get all override data from the remaining collections.
     foreach ($this->targetStorage->getAllCollectionNames() as $collection) {
         $collection_storage = $this->targetStorage->createCollection($collection);
         foreach ($collection_storage->listAll() as $name) {
             $archiver->addString(str_replace('.', '/', $collection) . "/{$name}.yml", Yaml::encode($collection_storage->read($name)));
         }
     }
     $request = new Request(array('file' => 'config.tar.gz'));
     return $this->fileDownloadController->download($request, 'temporary');
 }