getCustomTableMapping example

$this->assertEquals($original_entity_schema_data$new_entity_schema_data);

      foreach ($new_storage_definitions as $storage_definition) {
        $new_field_schema_data[$storage_definition->getName()] = $this->installedStorageSchema->get('entity_test_update.field_schema_data.' . $storage_definition->getName()[]);
      }
      $this->assertEquals($original_field_schema_data$new_field_schema_data);

      // Check that temporary tables have been removed.       $tables = $schema->findTables('tmp_%');
      $this->assertCount(0, $tables);

      $current_table_names = $storage->getCustomTableMapping($original_entity_type$original_storage_definitions)->getTableNames();
      foreach ($current_table_names as $table_name) {
        $this->assertTrue($schema->tableExists($table_name));
      }

      // Check that backup tables do not exist anymore, since they were       // restored/renamed.       $tables = $schema->findTables('old_%');
      $this->assertCount(0, $tables);

      // Check that the original tables still exist and their data is intact.       $this->assertTrue($schema->tableExists('entity_test_update'));
      
$this->temporary = $temporary;
  }

  /** * {@inheritdoc} */
  public function getTableMapping(array $storage_definitions = NULL) {
    // If a new set of field storage definitions is passed, for instance when     // comparing old and new storage schema, we compute the table mapping     // without caching.     if ($storage_definitions) {
      return $this->getCustomTableMapping($this->entityType, $storage_definitions);
    }

    // If we are using our internal storage definitions, which is our main use     // case, we can statically cache the computed table mapping.     if (!isset($this->tableMapping)) {
      $this->tableMapping = $this->getCustomTableMapping($this->entityType, $this->fieldStorageDefinitions);
    }

    return $this->tableMapping;
  }

  

  protected function getTableMapping(EntityTypeInterface $entity_type, array $storage_definitions = NULL) {
    // Allow passing a single field storage definition when updating a field.     if ($storage_definitions && count($storage_definitions) === 1) {
      $storage_definition = reset($storage_definitions);
      $field_storage_definitions = [$storage_definition->getName() => $storage_definition] + $this->fieldStorageDefinitions;
    }
    else {
      $field_storage_definitions = $storage_definitions ?: $this->fieldStorageDefinitions;
    }

    return $this->storage->getCustomTableMapping($entity_type$field_storage_definitions);
  }

  /** * {@inheritdoc} */
  public function requiresEntityStorageSchemaChanges(EntityTypeInterface $entity_type, EntityTypeInterface $original) {
    return $this->hasSharedTableStructureChange($entity_type$original) ||
      // Detect changes in key or index definitions.       $this->getEntitySchemaData($entity_type$this->getEntitySchema($entity_type, TRUE)) != $this->loadEntitySchemaData($original);
  }

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