function ContentEntityType::setRevisionMetadataKey

Same name and namespace in other branches
  1. 9 core/lib/Drupal/Core/Entity/ContentEntityType.php \Drupal\Core\Entity\ContentEntityType::setRevisionMetadataKey()
  2. 10 core/lib/Drupal/Core/Entity/ContentEntityType.php \Drupal\Core\Entity\ContentEntityType::setRevisionMetadataKey()
  3. 11.x core/lib/Drupal/Core/Entity/ContentEntityType.php \Drupal\Core\Entity\ContentEntityType::setRevisionMetadataKey()

Overrides ContentEntityTypeInterface::setRevisionMetadataKey

File

core/lib/Drupal/Core/Entity/ContentEntityType.php, line 120

Class

ContentEntityType
Provides an implementation of a content entity type and its metadata.

Namespace

Drupal\Core\Entity

Code

public function setRevisionMetadataKey($key, $field_name) {
    if ($field_name !== NULL) {
        // Update the property holding the required revision metadata keys,
        // which is used by the BC layer for retrieving the revision metadata
        // keys.
        // @see \Drupal\Core\Entity\ContentEntityType::getRevisionMetadataKeys()
        $this->requiredRevisionMetadataKeys[$key] = $field_name;
        // Add the new revision metadata key.
        $this->revision_metadata_keys[$key] = $field_name;
    }
    else {
        unset($this->requiredRevisionMetadataKeys[$key], $this->revision_metadata_keys[$key]);
    }
    return $this;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.