protected SqlContentEntityStorage::saveToSharedTables(ContentEntityInterface $entity, $table_name = NULL, $new_revision = NULL)
Saves fields that use the shared tables.
\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.
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(); }
© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Entity!Sql!SqlContentEntityStorage.php/function/SqlContentEntityStorage::saveToSharedTables/8.1.x