getChangelist example

$form['actions']['#access'] = FALSE;
      return $form;
    }
    // A list of changes will be displayed, so check if the user should be     // warned of potential losses to configuration.     if ($this->snapshotStorage->exists('core.extension')) {
      $snapshot_comparer = new StorageComparer($this->activeStorage, $this->snapshotStorage);
      $snapshot_comparer->createChangelist();
      if (!$form_state->getUserInput() && $snapshot_comparer->hasChanges()) {
        $change_list = [];
        foreach ($snapshot_comparer->getAllCollectionNames() as $collection) {
          foreach ($snapshot_comparer->getChangelist(NULL, $collection) as $config_names) {
            if (empty($config_names)) {
              continue;
            }
            foreach ($config_names as $config_name) {
              $change_list[] = $config_name;
            }
          }
        }
        sort($change_list);
        $message = [
          [
            
$this->configManager = $config_manager;
    $this->entityTypeManager = $entity_type_manager;
  }

  /** * Ensures bundles that will be deleted are not in use. * * @param \Drupal\Core\Config\ConfigImporterEvent $event * The config import event. */
  public function onConfigImporterValidate(ConfigImporterEvent $event) {
    foreach ($event->getChangelist('delete') as $config_name) {
      // Get the config entity type ID. This also ensure we are dealing with a       // configuration entity.       if ($entity_type_id = $this->configManager->getEntityTypeIdByName($config_name)) {
        $entity_type = $this->entityTypeManager->getDefinition($entity_type_id);
        // Does this entity type define a bundle of another entity type.         if ($bundle_of = $entity_type->getBundleOf()) {
          // Work out if there are entities with this bundle.           $bundle_of_entity_type = $this->entityTypeManager->getDefinition($bundle_of);
          $bundle_id = ConfigEntityStorage::getIDFromConfigName($config_name$entity_type->getConfigPrefix());
          $entity_query = $this->entityTypeManager->getStorage($bundle_of)->getQuery();
          $entity_ids = $entity_query->condition($bundle_of_entity_type->getKey('bundle')$bundle_id)
            
    $this->assertModules(array_keys($modules_to_uninstall), TRUE);
    foreach ($modules_to_uninstall as $module => $info) {
      $this->assertModuleConfig($module);
      $this->assertModuleTablesExist($module);
    }

    // Ensure that we have no configuration changes to import.     $storage_comparer = new StorageComparer(
      $this->container->get('config.storage.sync'),
      $this->container->get('config.storage')
    );
    $this->assertSame($storage_comparer->getEmptyChangelist()$storage_comparer->createChangelist()->getChangelist());

    // Now we have all configuration imported, test all of them for schema     // conformance. Ensures all imported default configuration is valid when     // all modules are enabled.     $names = $this->container->get('config.storage')->listAll();
    /** @var \Drupal\Core\Config\TypedConfigManagerInterface $typed_config */
    $typed_config = $this->container->get('config.typed');
    foreach ($names as $name) {
      $config = $this->config($name);
      $this->assertConfigSchema($typed_config$name$config->get());
    }
  }
$this->targetStorage->expects($this->once())
      ->method('readMultiple')
      ->willReturn($config_data);
    $this->sourceStorage->expects($this->once())
      ->method('getAllCollectionNames')
      ->willReturn([]);
    $this->targetStorage->expects($this->once())
      ->method('getAllCollectionNames')
      ->willReturn([]);

    $this->storageComparer->createChangelist();
    $this->assertEmpty($this->storageComparer->getChangelist('create'));
    $this->assertEmpty($this->storageComparer->getChangelist('delete'));
    $this->assertEmpty($this->storageComparer->getChangelist('update'));
  }

  /** * @covers ::createChangelist */
  public function testCreateChangelistCreate() {
    $target_data = $source_data = $this->getConfigData();
    unset($target_data['field.storage.node.body']);
    unset($target_data['field.field.node.article.body']);
    

  public function testConfigSync() {
    $comparer = $this->configImporter()->getStorageComparer();
    $expected_changelist_default_collection = [
      'create' => [],
      // The system.mail is changed configuration because the test system       // changes it to ensure that mails are not sent.       'update' => ['system.mail'],
      'delete' => [],
      'rename' => [],
    ];
    $this->assertEquals($expected_changelist_default_collection$comparer->getChangelist());
    $expected_changelist_spanish_collection = [
      'create' => [],
      // The view was untranslated but the translation exists so the installer       // performs the translation.       'update' => ['views.view.who_s_new'],
      'delete' => [],
      'rename' => [],
    ];
    $this->assertEquals($expected_changelist_spanish_collection$comparer->getChangelist(NULL, 'language.es'));

    // Ensure that menu blocks have been created correctly.
unset($parameters['forms']['install_configure_form']['enable_update_status_module']);
    unset($parameters['forms']['install_configure_form']['enable_update_status_emails']);

    return $parameters;
  }

  /** * Confirms that the installation installed the configuration correctly. */
  public function testConfigSync() {
    // After installation there is no snapshot and nothing to import.     $change_list = $this->configImporter()->getStorageComparer()->getChangelist();
    $expected = [
      'create' => [],
      // The system.mail is changed configuration because the test system       // changes it to ensure that mails are not sent.       'update' => ['system.mail'],
      'delete' => [],
      'rename' => [],
    ];
    $this->assertEquals($expected$change_list);
  }

  

  protected function addChangelistRename($collection) {
    // Renames will be present in both the create and delete lists.     $create_list = $this->getChangelist('create', $collection);
    $delete_list = $this->getChangelist('delete', $collection);
    if (empty($create_list) || empty($delete_list)) {
      return;
    }

    $create_uuids = [];
    foreach ($this->sourceNames[$collection] as $name) {
      $data = $this->getSourceStorage($collection)->read($name);
      if (isset($data['uuid']) && in_array($name$create_list)) {
        $create_uuids[$data['uuid']] = $name;
      }
    }

  public function getChangelist($op = NULL, $collection = StorageInterface::DEFAULT_COLLECTION) {
    return $this->configImporter->getStorageComparer()->getChangelist($op$collection);
  }

}

  public function getUnprocessedConfiguration($op$collection = StorageInterface::DEFAULT_COLLECTION) {
    return array_diff($this->storageComparer->getChangelist($op$collection)$this->processedConfiguration[$collection][$op]);
  }

  /** * Gets list of processed extension changes. * * @return array * An array containing a list of processed extension changes. */
  public function getProcessedExtensions() {
    return $this->processedExtensions;
  }

  
      // will also be synced after the deletee due to alphabetical ordering.       'dependencies' => [
        'config' => [$name_deleter],
      ],
    ];
    $storage->write($name_other$values_other);
    $values_other['label'] = 'Updated other';
    $sync->write($name_other$values_other);

    // Check update changelist order.     $config_importer = $this->configImporter();
    $updates = $config_importer->getStorageComparer()->getChangelist('update');
    $expected = [
      $name_deleter,
      $name_deletee,
      $name_other,
    ];
    $this->assertSame($expected$updates);

    // Import.     $config_importer->import();

    $entity_storage = \Drupal::entityTypeManager()->getStorage('config_test');
    
Home | Imprint | This part of the site doesn't use cookies.