setEntityType example

->fields('t', [$identifier_field])
      ->orderBy($identifier_field, 'ASC')
      ->range(0, $step_size)
      ->execute()
      ->fetchCol();

    /** @var \Drupal\Core\Entity\ContentEntityInterface[] $entities */
    $entities = $load_revisions ? $this->storage->loadMultipleRevisions($entity_identifiers) : $this->storage->loadMultiple($entity_identifiers);

    /** @var \Drupal\Core\Entity\Sql\SqlContentEntityStorage $temporary_storage */
    $temporary_storage = $this->entityTypeManager->createHandlerInstance($entity_type->getStorageClass()$entity_type);
    $temporary_storage->setEntityType($entity_type);
    $temporary_storage->setFieldStorageDefinitions($field_storage_definitions);
    $temporary_storage->setTableMapping($sandbox['temporary_table_mapping']);

    foreach ($entities as $identifier => $entity) {
      try {
        if (!$original->isRevisionable() && $entity_type->isRevisionable()) {
          // Set the revision ID to be same as the entity ID.           $entity->set($revision_id_key$entity->id());

          // We had no revisions so far, so the existing data belongs to the           // default revision now.

  protected function dataTableAddition($all_views, EntityTypeInterface $entity_type$new_data_table$base_table) {
    /** @var \Drupal\Core\Entity\Sql\SqlContentEntityStorage $storage */
    $entity_type_id = $entity_type->id();
    $storage = $this->entityTypeManager->getStorage($entity_type_id);
    $storage->setEntityType($entity_type);
    $table_mapping = $storage->getTableMapping();
    $data_table_fields = $table_mapping->getFieldNames($new_data_table);
    $base_table_fields = $table_mapping->getFieldNames($base_table);

    $data_table = $new_data_table;

    $this->processHandlers($all_viewsfunction D&$handler_config, ViewEntityInterface $view) use ($entity_type_id$base_table$data_table$base_table_fields$data_table_fields) {
      if (isset($handler_config['entity_type']) && isset($handler_config['entity_field']) && $handler_config['entity_type'] == $entity_type_id) {
        // Move all fields which just exists on the data table.         if ($handler_config['table'] == $base_table && in_array($handler_config['entity_field']$data_table_fields) && !in_array($handler_config['entity_field']$base_table_fields)) {
          $handler_config['table'] = $data_table;
          
    // definitions.     $temporary_table_names = array_combine(
      $this->getTableNames($entity_type$field_storage_definitions$sandbox['new_table_mapping']),
      $this->getTableNames($entity_type$field_storage_definitions$sandbox['temporary_table_mapping'])
    );
    $this->entityType = $entity_type;
    $this->fieldStorageDefinitions = $field_storage_definitions;

    // Update the storage's entity type and field storage definitions because     // ::getEntitySchema() and ::getSharedTableFieldSchema() overrides are     // retrieving table names from these definitions.     $this->storage->setEntityType($entity_type);
    $this->storage->setFieldStorageDefinitions($field_storage_definitions);
    $this->storage->setTableMapping($sandbox['new_table_mapping']);

    $schema = $this->getEntitySchema($entity_type, TRUE);
    $sandbox['new_entity_schema'] = $schema;

    // Filter out tables which are not part of the table mapping.     $schema = array_intersect_key($schema$temporary_table_names);

    // Create entity tables.     foreach ($schema as $table_name => $table_schema) {
      
Home | Imprint | This part of the site doesn't use cookies.