public function ConfigEntityRevisionsRevisionStorageHandler::loadConfigEntityRevision in Config Entity Revisions 8.2
Load a particular revision of a config entity.
Parameters
int $revision: The revision ID to load.
mixed $entity: The entity type to load.
Return value
mixed The loaded revision or NULL.
Overrides ConfigEntityRevisionsRevisionStorageHandlerInterface::loadConfigEntityRevision
File
- src/
Entity/ Handler/ ConfigEntityRevisionsRevisionStorageHandler.php, line 586
Class
- ConfigEntityRevisionsRevisionStorageHandler
- Class ConfigEntityRevisionsRevisionStorageHandler.
Namespace
Drupal\config_entity_revisions\Entity\HandlerCode
public function loadConfigEntityRevision($revision = NULL, $entity = '') {
$config_entity_name = $this
->configEntityName();
if (!$entity) {
$match = \Drupal::service('router')
->matchRequest(\Drupal::request());
$entity = $match[$config_entity_name];
}
if (is_string($entity)) {
$entity = $this->entityTypeManager
->getStorage($config_entity_name)
->load($entity);
}
if ($revision) {
$revisionsEntity = $this->entityTypeManager
->getStorage('config_entity_revisions')
->loadRevision($revision);
$entity = \Drupal::getContainer()
->get('serializer')
->deserialize($revisionsEntity
->get('configuration')->value, get_class($entity), 'json');
// The result of serialising and then deserialising is not an exact
// copy of the original. This causes problems downstream if we don't fix
// a few attributes here.
$entity
->set('settingsOriginal', $entity
->get('settings'));
$entity
->set('enforceIsNew', FALSE);
}
return $entity;
}