getUpdatedFieldStorageDefinitions example



  /** * Updates the entity type definition. * * @param bool $alter * Whether the original definition should be altered or not. */
  protected function updateEntityType($alter) {
    $this->state->set('entity_schema_update', $alter);
    $updated_entity_type = $this->getUpdatedEntityTypeDefinition($alter$alter);
    $updated_field_storage_definitions = $this->getUpdatedFieldStorageDefinitions($alter$alter);
    $this->container->get('entity.definition_update_manager')->updateFieldableEntityType($updated_entity_type$updated_field_storage_definitions);
  }

  /** * Tests that entity schema responds to changes in the entity type definition. */
  public function testEntitySchemaUpdate() {
    $this->installModule('entity_schema_test');
    $storage_definitions = \Drupal::service('entity_field.manager')->getFieldStorageDefinitions('entity_test_update');
    \Drupal::service('field_storage_definition.listener')->onFieldStorageDefinitionCreate($storage_definitions['custom_base_field']);
    \Drupal::service('field_storage_definition.listener')->onFieldStorageDefinitionCreate($storage_definitions['custom_bundle_field']);
    
/** * @covers ::updateFieldableEntityType * @dataProvider providerTestFieldableEntityTypeUpdates */
  public function testFieldableEntityTypeUpdates($initial_rev$initial_mul$new_rev$new_mul$data_migration_supported) {
    // The 'entity_test_update' entity type is neither revisionable nor     // translatable by default, so we need to get it into the initial testing     // state. This also covers the "no existing data" scenario for fieldable     // entity type updates.     if ($initial_rev || $initial_mul) {
      $entity_type = $this->getUpdatedEntityTypeDefinition($initial_rev$initial_mul);
      $field_storage_definitions = $this->getUpdatedFieldStorageDefinitions($initial_rev$initial_mul);

      $this->entityDefinitionUpdateManager->updateFieldableEntityType($entity_type$field_storage_definitions);
      $this->assertEntityTypeSchema($initial_rev$initial_mul);
    }

    // Add a few entities so we can test the data copying step.     $this->insertData($initial_rev$initial_mul);

    $updated_entity_type = $this->getUpdatedEntityTypeDefinition($new_rev$new_mul);
    $updated_field_storage_definitions = $this->getUpdatedFieldStorageDefinitions($new_rev$new_mul);

    

  protected function enableNewEntityType() {
    $this->state->set('entity_test_new', TRUE);
    $this->applyEntityUpdates('entity_test_new');
  }

  /** * Resets the entity type definition. */
  protected function resetEntityType() {
    $updated_entity_type = $this->getUpdatedEntityTypeDefinition(FALSE, FALSE);
    $updated_field_storage_definitions = $this->getUpdatedFieldStorageDefinitions(FALSE, FALSE);
    $this->entityDefinitionUpdateManager->updateFieldableEntityType($updated_entity_type$updated_field_storage_definitions);
  }

  /** * Updates the 'entity_test_update' entity type to revisionable. * * @param bool $perform_update * (optional) Whether the change should be performed by the entity * definition update manager. */
  protected function updateEntityTypeToRevisionable($perform_update = FALSE) {
    
Home | Imprint | This part of the site doesn't use cookies.