requiresEntityDataMigration example

/** * {@inheritdoc} */
  public function requiresFieldStorageSchemaChanges(FieldStorageDefinitionInterface $storage_definition, FieldStorageDefinitionInterface $original) {
    return $this->getStorageSchema()->requiresFieldStorageSchemaChanges($storage_definition$original);
  }

  /** * {@inheritdoc} */
  public function requiresEntityDataMigration(EntityTypeInterface $entity_type, EntityTypeInterface $original) {
    return $this->getStorageSchema()->requiresEntityDataMigration($entity_type$original);
  }

  /** * {@inheritdoc} */
  public function requiresFieldDataMigration(FieldStorageDefinitionInterface $storage_definition, FieldStorageDefinitionInterface $original) {
    return $this->getStorageSchema()->requiresFieldDataMigration($storage_definition$original);
  }

  /** * {@inheritdoc} */

    }
    $this->entityTypeListener->onFieldableEntityTypeCreate($entity_type$field_storage_definitions);
  }

  /** * {@inheritdoc} */
  public function updateFieldableEntityType(EntityTypeInterface $entity_type, array $field_storage_definitions, array &$sandbox = NULL) {
    $original = $this->getEntityType($entity_type->id());

    if ($this->requiresEntityDataMigration($entity_type$original) && $sandbox === NULL) {
      throw new \InvalidArgumentException('The entity schema update for the ' . $entity_type->id() . ' entity type requires a data migration.');
    }

    $original_field_storage_definitions = $this->entityLastInstalledSchemaRepository->getLastInstalledFieldStorageDefinitions($entity_type->id());
    $this->entityTypeListener->onFieldableEntityTypeUpdate($entity_type$original$field_storage_definitions$original_field_storage_definitions$sandbox);
    $this->clearCachedDefinitions();
  }

  /** * {@inheritdoc} */
  
$this->storageSchema = $this->getMockBuilder('Drupal\Core\Entity\Sql\SqlContentEntityStorageSchema')
      ->setConstructorArgs([$this->entityTypeManager->reveal()$this->entityType, $this->storage, $connection$this->entityFieldManager->reveal()$this->entityLastInstalledSchemaRepository])
      ->onlyMethods(['installedStorageSchema', 'hasSharedTableStructureChange'])
      ->getMock();

    $this->storageSchema->expects($this->any())
      ->method('hasSharedTableStructureChange')
      ->with($updated_entity_type_definition$original_entity_type_definition)
      ->willReturn($shared_table_structure_changed);

    $this->assertEquals($migration_required$this->storageSchema->requiresEntityDataMigration($updated_entity_type_definition$original_entity_type_definition));
  }

  /** * Data provider for ::testRequiresEntityStorageSchemaChanges(). */
  public function providerTestRequiresEntityStorageSchemaChanges() {

    $cases = [];

    $updated_entity_type_definition = $this->createMock('\Drupal\Core\Entity\ContentEntityTypeInterface');
    $original_entity_type_definition = $this->createMock('\Drupal\Core\Entity\ContentEntityTypeInterface');

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