public function ConfigEntityRevisionsRevertFormBase::__construct in Config Entity Revisions 8.2
Same name and namespace in other branches
- 8 src/ConfigEntityRevisionsRevertFormBase.php \Drupal\config_entity_revisions\ConfigEntityRevisionsRevertFormBase::__construct()
- 1.x src/ConfigEntityRevisionsRevertFormBase.php \Drupal\config_entity_revisions\ConfigEntityRevisionsRevertFormBase::__construct()
Constructs a new class instance.
Parameters
\Drupal\Core\Entity\EntityTypeManager $entity_type_manager: The entity type manager.
\Drupal\Core\Datetime\DateFormatterInterface $date_formatter: The date formatter service.
\Drupal\Component\Datetime\TimeInterface $time: The time service.
\Drupal\Core\Messenger\MessengerInterface $messenger: The messenger service.
File
- src/
ConfigEntityRevisionsRevertFormBase.php, line 99
Class
- ConfigEntityRevisionsRevertFormBase
- Class ConfigEntityRevisionsRevertFormBase.
Namespace
Drupal\config_entity_revisionsCode
public function __construct(EntityTypeManager $entity_type_manager, DateFormatterInterface $date_formatter, TimeInterface $time, MessengerInterface $messenger) {
$this->entityTypeManager = $entity_type_manager;
$this->dateFormatter = $date_formatter;
$this->time = $time;
$this->messenger = $messenger;
$match = \Drupal::service('router')
->matchRequest(\Drupal::request());
$this->configEntity = $match['config_entity']
->revisionedEntity();
$this->revisionId = $match['revision_id'];
$this->revision = $this->configEntity
->contentEntityStorage()
->loadRevision($this->revisionId);
$revisionsID = $this->configEntity
->getContentEntityId();
$latest_published = $this->configEntity
->contentEntityStorage()
->getLatestPublishedRevision();
$publish = is_null($latest_published) || $this->revision
->getRevisionId() > $latest_published
->getRevisionId();
$this->action = $publish ? 'publish' : 'revert';
}