protected SqlContentEntityStorage::saveToSharedTables(ContentEntityInterface $entity, $table_name = NULL, $new_revision = NULL)
Saves fields that use the shared tables.
Parameters
\Drupal\Core\Entity\ContentEntityInterface $entity: The entity object.
string $table_name: (optional) The table name to save to. Defaults to the data table.
bool $new_revision: (optional) Whether we are dealing with a new revision. By default fetches the information from the entity object.
File
- core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php, line 888
Class
- SqlContentEntityStorage
- A content entity database storage implementation.
Namespace
Drupal\Core\Entity\Sql
Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | protected function saveToSharedTables(ContentEntityInterface $entity , $table_name = NULL, $new_revision = NULL) { if (!isset( $table_name )) { $table_name = $this ->dataTable; } if (!isset( $new_revision )) { $new_revision = $entity ->isNewRevision(); } $revision = $table_name != $this ->dataTable; if (! $revision || ! $new_revision ) { $key = $revision ? $this ->revisionKey : $this ->idKey; $value = $revision ? $entity ->getRevisionId() : $entity ->id(); // Delete and insert to handle removed values. $this ->database-> delete ( $table_name ) ->condition( $key , $value ) ->execute(); } $query = $this ->database->insert( $table_name ); foreach ( $entity ->getTranslationLanguages() as $langcode => $language ) { $translation = $entity ->getTranslation( $langcode ); $record = $this ->mapToDataStorageRecord( $translation , $table_name ); $values = ( array ) $record ; $query ->fields( array_keys ( $values )) ->values( $values ); } $query ->execute(); } |
Please login to continue.