extractRenameNames example

protected function removeFromChangelist($collection$op$name) {
    $key = array_search($name$this->changelist[$collection][$op]);
    if ($key !== FALSE) {
      unset($this->changelist[$collection][$op][$key]);
    }
  }

  /** * {@inheritdoc} */
  public function moveRenameToUpdate($rename$collection = StorageInterface::DEFAULT_COLLECTION) {
    $names = $this->extractRenameNames($rename);
    $this->removeFromChangelist($collection, 'rename', $rename);
    $this->addChangeList($collection, 'update', [$names['new_name']]$this->sourceNames[$collection]);
  }

  /** * {@inheritdoc} */
  public function reset() {
    $this->changelist = [StorageInterface::DEFAULT_COLLECTION => $this->getEmptyChangelist()];
    $this->sourceNames = $this->targetNames = [];
    // Reset the static configuration data caches.
case 'rename':
            $form[$collection][$config_change_type]['heading']['#value'] = $this->formatPlural(count($config_names), '@count renamed', '@count renamed');
            break;
        }
        $form[$collection][$config_change_type]['list'] = [
          '#type' => 'table',
          '#header' => [$this->t('Name')$this->t('Operations')],
        ];

        foreach ($config_names as $config_name) {
          if ($config_change_type == 'rename') {
            $names = $storage_comparer->extractRenameNames($config_name);
            $route_options = ['source_name' => $names['old_name'], 'target_name' => $names['new_name']];
            $config_name = $this->t('@source_name to @target_name', ['@source_name' => $names['old_name'], '@target_name' => $names['new_name']]);
          }
          else {
            $route_options = ['source_name' => $config_name];
          }
          if ($collection != StorageInterface::DEFAULT_COLLECTION) {
            $route_name = 'config.diff_collection';
            $route_options['collection'] = $collection;
          }
          else {
            

  public function validate() {
    if (!$this->validated) {
      $this->errors = [];
      // Create the list of installs and uninstalls.       $this->createExtensionChangelist();
      // Validate renames.       foreach ($this->getUnprocessedConfiguration('rename') as $name) {
        $names = $this->storageComparer->extractRenameNames($name);
        $old_entity_type_id = $this->configManager->getEntityTypeIdByName($names['old_name']);
        $new_entity_type_id = $this->configManager->getEntityTypeIdByName($names['new_name']);
        if ($old_entity_type_id != $new_entity_type_id) {
          $this->logError($this->t('Entity type mismatch on rename. @old_type not equal to @new_type for existing configuration @old_name and staged configuration @new_name.', ['@old_type' => $old_entity_type_id, '@new_type' => $new_entity_type_id, '@old_name' => $names['old_name'], '@new_name' => $names['new_name']]));
        }
        // Has to be a configuration entity.         if (!$old_entity_type_id) {
          $this->logError($this->t('Rename operation for simple configuration. Existing configuration @old_name and staged configuration @new_name.', ['@old_name' => $names['old_name'], '@new_name' => $names['new_name']]));
        }
      }
      $this->eventDispatcher->dispatch(new ConfigImporterEvent($this), ConfigEvents::IMPORT_VALIDATE);
      
Home | Imprint | This part of the site doesn't use cookies.