trait ConfigEntityRevisionsConfigTrait in Config Entity Revisions 8
Same name and namespace in other branches
- 1.x src/ConfigEntityRevisionsConfigTrait.php \Drupal\config_entity_revisions\ConfigEntityRevisionsConfigTrait
Hierarchy
- trait \Drupal\config_entity_revisions\ConfigEntityRevisionsConfigTrait
4 files declare their use of ConfigEntityRevisionsConfigTrait
- ViewsRevisions.php in modules/
views_revisions/ src/ Entity/ ViewsRevisions.php - ViewsRevisionsUI.php in modules/
views_revisions/ src/ ViewsRevisionsUI.php - WebformRevisions.php in modules/
webform_revisions/ src/ Entity/ WebformRevisions.php - WebformRevisionsSubmission.php in modules/
webform_revisions/ src/ Entity/ WebformRevisionsSubmission.php
File
- src/
ConfigEntityRevisionsConfigTrait.php, line 9
Namespace
Drupal\config_entity_revisionsView source
trait ConfigEntityRevisionsConfigTrait {
/**
* @var int
* The ID of the revision that was loaded.
*/
public $loadedRevisionId;
/**
* Restore the entity type manager after deserialisation.
*/
public function __wakeup() {
$this->entityTypeManager = \Drupal::service('entity_type.manager');
}
/**
* Gets the revision identifier of the entity.
*
* @return int
* The revision identifier of the entity, or NULL if the entity does not
* have a revision identifier.
*/
public function getRevisionId() {
return $this->loadedRevisionId;
}
/**
* Set revision ID.
*
* @param int $revisionID
* The revision ID that this class instance represents.
*/
public function updateLoadedRevisionId($revisionID) {
$this->loadedRevisionId = $revisionID;
}
/**
* Get the config entity storage.
*
* @return ConfigEntityStorageInterface
* The storage for the config entity.
*
* @throws \Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException
* @throws \Drupal\Component\Plugin\Exception\PluginNotFoundException
*/
public function configEntityStorage() {
return $this->entityTypeManager
->getStorage('config_entity_revisions');
}
/**
* Get the revisions entity storage.
*
* @return ContentEntityStorageInterface
* The storage for the revisions entity.
*
* @throws \Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException
* @throws \Drupal\Component\Plugin\Exception\PluginNotFoundException
*/
public function contentEntityStorage() {
return $this->entityTypeManager
->getStorage('config_entity_revisions');
}
/**
* Default revision of revisions entity that matches the config entity.
*
* @return \Drupal\Core\Entity\EntityInterface|null
* The matching entity.
*
* @throws \Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException
* @throws \Drupal\Component\Plugin\Exception\PluginNotFoundException
*/
public function getContentEntity() {
$contentEntityID = $this
->getContentEntityID();
if (!$contentEntityID) {
return NULL;
}
/* @var $storage \Drupal\Core\Entity\ContentEntityStorageInterface */
$storage = $this
->contentEntityStorage();
// Get the matching revision ID if one is provided.
if ($this
->getRevisionId()) {
return $storage
->loadRevision($this
->getRevisionId());
}
// Otherwise, just get the default revision.
return $storage
->load($contentEntityID);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ConfigEntityRevisionsConfigTrait:: |
public | property | The ID of the revision that was loaded. | |
ConfigEntityRevisionsConfigTrait:: |
public | function | Get the config entity storage. | |
ConfigEntityRevisionsConfigTrait:: |
public | function | Get the revisions entity storage. | |
ConfigEntityRevisionsConfigTrait:: |
public | function | Default revision of revisions entity that matches the config entity. | |
ConfigEntityRevisionsConfigTrait:: |
public | function | Gets the revision identifier of the entity. | |
ConfigEntityRevisionsConfigTrait:: |
public | function | Set revision ID. | |
ConfigEntityRevisionsConfigTrait:: |
public | function | Restore the entity type manager after deserialisation. |