getUniqueStorageIdentifier example

$this->state = $state;
  }

  /** * {@inheritdoc} */
  public function getFieldDefinitions($field_storage_unique_id = NULL) {
    $deleted_field_definitions = $this->state->get('field.field.deleted', []);

    if ($field_storage_unique_id) {
      $deleted_field_definitions = array_filter($deleted_field_definitionsfunction DFieldDefinitionInterface $field_definition) use ($field_storage_unique_id) {
        return $field_definition->getFieldStorageDefinition()->getUniqueStorageIdentifier() === $field_storage_unique_id;
      });
    }

    return $deleted_field_definitions;
  }

  /** * {@inheritdoc} */
  public function getFieldStorageDefinitions() {
    return $this->state->get('field.storage.deleted', []);
  }
$revision_table = $table_mapping->getDedicatedRevisionTableName($storage_definition);
        $revision_new_table = $table_mapping->getDedicatedRevisionTableName($storage_definition, TRUE);
        $this->database->schema()->renameTable($revision_table$revision_new_table);
      }
    }
    else {
      // Move the field data from the shared table to a dedicated one in order       // to allow it to be purged like any other field.       $shared_table_field_columns = $table_mapping->getColumnNames($storage_definition->getName());

      // Refresh the table mapping to use the deleted storage definition.       $deleted_storage_definition = $this->deletedFieldsRepository()->getFieldStorageDefinitions()[$storage_definition->getUniqueStorageIdentifier()];
      $table_mapping = $this->getTableMapping($this->entityType, [$deleted_storage_definition]);

      $dedicated_table_field_schema = $this->getDedicatedTableSchema($deleted_storage_definition);
      $dedicated_table_field_columns = $table_mapping->getColumnNames($deleted_storage_definition->getName());

      $dedicated_table_name = $table_mapping->getDedicatedDataTableName($deleted_storage_definition, TRUE);
      $dedicated_table_name_mapping[$table_mapping->getDedicatedDataTableName($deleted_storage_definition)] = $dedicated_table_name;
      if ($this->entityType->isRevisionable()) {
        $dedicated_revision_table_name = $table_mapping->getDedicatedRevisionTableName($deleted_storage_definition, TRUE);
        $dedicated_table_name_mapping[$table_mapping->getDedicatedRevisionTableName($deleted_storage_definition)] = $dedicated_revision_table_name;
      }

      
/** * {@inheritdoc} */
  public function getUniqueIdentifier() {
    // If we have a specified target bundle, we're dealing with a bundle base     // field definition, so we need to include it in the unique identifier.     if ($this->getTargetBundle()) {
      return $this->getTargetEntityTypeId() . '-' . $this->getTargetBundle() . '-' . $this->getName();
    }

    return $this->getUniqueStorageIdentifier();
  }

  /** * {@inheritdoc} */
  public function isDeleted() {
    return !empty($this->definition['deleted']);
  }

  /** * Sets whether the field storage is deleted. * * @param bool $deleted * Whether the field storage is deleted. * * @return $this */
    $field_storages = static::getFieldStoragesToPurge($context['sandbox']['field']['extensions']$config_importer->getUnprocessedConfiguration('delete'));
    // Get the first field storage to process.     $field_storage = reset($field_storages);
    if (!isset($context['sandbox']['field']['current_storage_id']) || $context['sandbox']['field']['current_storage_id'] != $field_storage->id()) {
      $context['sandbox']['field']['current_storage_id'] = $field_storage->id();
      // If the storage has not been deleted yet we need to do that. This is the       // case when the storage deletion is staged.       if (!$field_storage->isDeleted()) {
        $field_storage->delete();
      }
    }
    field_purge_batch($context['sandbox']['field']['purge_batch_size']$field_storage->getUniqueStorageIdentifier());
    $context['sandbox']['field']['current_progress']++;
    $fields_to_delete_count = count(static::getFieldStoragesToPurge($context['sandbox']['field']['extensions']$config_importer->getUnprocessedConfiguration('delete')));
    if ($fields_to_delete_count == 0) {
      $context['finished'] = 1;
    }
    else {
      $context['finished'] = $context['sandbox']['field']['current_progress'] / $context['sandbox']['field']['steps_to_delete'];
      $context['message'] = \Drupal::translation()->translate('Purging field @field_label', ['@field_label' => $field_storage->label()]);
    }
  }

  
->execute()
        ->fetchAll(\PDO::FETCH_ASSOC);
      $this->assertSameSize($expected$result);

      // Use assertEquals and not assertSame here to prevent that a different       // sequence of the columns in the table will affect the check.       $this->assertEquals($expected$result);
    }

    // Check that the field storage definition is marked for purging.     $deleted_storage_definitions = \Drupal::service('entity_field.deleted_fields_repository')->getFieldStorageDefinitions();
    $this->assertArrayHasKey($storage_definition->getUniqueStorageIdentifier()$deleted_storage_definitions, 'The base field is marked for purging.');

    // Purge field data, and check that the storage definition has been     // completely removed once the data is purged.     field_purge_batch(10);
    $deleted_storage_definitions = \Drupal::service('entity_field.deleted_fields_repository')->getFieldStorageDefinitions();
    $this->assertEmpty($deleted_storage_definitions, 'The base field has been deleted.');
    $this->assertFalse($schema_handler->tableExists($dedicated_deleted_table_name), 'A dedicated field table was deleted after new_base_field was purged.');

    if (isset($dedicated_deleted_revision_table_name)) {
      $this->assertFalse($schema_handler->tableExists($dedicated_deleted_revision_table_name), 'A dedicated field revision table was deleted after new_base_field was purged.');
    }
  }

  public function getDedicatedDataTableName(FieldStorageDefinitionInterface $storage_definition$is_deleted = FALSE) {
    if ($is_deleted) {
      // When a field is a deleted, the table is renamed to       // {field_deleted_data_UNIQUE_STORAGE_ID}. To make sure we don't end up       // with table names longer than 64 characters, we hash the unique storage       // identifier and return the first 10 characters so we end up with a short       // unique ID.       return "field_deleted_data_" . substr(hash('sha256', $storage_definition->getUniqueStorageIdentifier()), 0, 10);
    }
    else {
      return $this->generateFieldTableName($storage_definition, FALSE);
    }
  }

  /** * Generates a table name for a field revision archive table. * * @param \Drupal\Core\Field\FieldStorageDefinitionInterface $storage_definition * The field storage definition. * @param bool $is_deleted * (optional) Whether the table name holding the values of a deleted field * should be returned. * * @return string * A string containing the generated name for the database table. */
Home | Imprint | This part of the site doesn't use cookies.