class LatestRevisionUpdateRunner in Scheduled Updates 8
The Latest Revision Update Runner.
@todo Is spliting the description onto multiple lines a good idea? It works but is ugly.
Plugin annotation
@UpdateRunner(
id = "latest_revision",
label = @Translation("Latest Revision"),
update_types = {"embedded"},
description = @Translation("Runs updates always against the latest revision of revisionable entities content.")
)
Hierarchy
- class \Drupal\Component\Plugin\PluginBase implements DerivativeInspectionInterface, PluginInspectionInterface
- class \Drupal\Core\Plugin\PluginBase uses DependencySerializationTrait, MessengerTrait, StringTranslationTrait
- class \Drupal\scheduled_updates\Plugin\BaseUpdateRunner implements UpdateRunnerInterface uses ClassUtilsTrait
- class \Drupal\scheduled_updates\Plugin\UpdateRunner\EmbeddedUpdateRunner implements EntityMonitorUpdateRunnerInterface
- class \Drupal\scheduled_updates\Plugin\UpdateRunner\LatestRevisionUpdateRunner
- class \Drupal\scheduled_updates\Plugin\UpdateRunner\EmbeddedUpdateRunner implements EntityMonitorUpdateRunnerInterface
- class \Drupal\scheduled_updates\Plugin\BaseUpdateRunner implements UpdateRunnerInterface uses ClassUtilsTrait
- class \Drupal\Core\Plugin\PluginBase uses DependencySerializationTrait, MessengerTrait, StringTranslationTrait
Expanded class hierarchy of LatestRevisionUpdateRunner
File
- src/
Plugin/ UpdateRunner/ LatestRevisionUpdateRunner.php, line 27 - Contains \Drupal\scheduled_updates\Plugin\UpdateRunner\LatestRevisionUpdateRunner
Namespace
Drupal\scheduled_updates\Plugin\UpdateRunnerView source
class LatestRevisionUpdateRunner extends EmbeddedUpdateRunner {
/*
* Runs updates always against the latest revision of revisionable entities content.
*
*/
/**
* {@inheritdoc}
*
* This method is overridden because the version in BaseUpdateRunner only needs
* to get default revisions so does not call $query->allRevisions().
*
* $query->condition("$field_id.entity.update_timestamp", $all_ready_update_ids, 'IN');
*
*/
protected function getEntityIdsReferencingReadyUpdates() {
$entity_ids = [];
if ($field_ids = $this
->getReferencingFieldIds()) {
$entity_storage = $this->entityTypeManager
->getStorage($this
->updateEntityType());
$all_ready_update_ids = $this
->getReadyUpdateIds();
if ($all_ready_update_ids) {
foreach ($field_ids as $field_id) {
$query = $entity_storage
->getQuery('AND');
$query
->condition("{$field_id}.target_id", $all_ready_update_ids, 'IN');
$query
->allRevisions();
$entity_ids += $query
->execute();
}
}
}
return $entity_ids;
}
/**
* {@inheritdoc}
*/
protected function loadEntitiesToUpdate($entity_ids) {
$revision_ids = array_keys($entity_ids);
$entity_ids = array_unique($entity_ids);
$revisions = [];
foreach ($entity_ids as $entity_id) {
/** @var ContentEntityInterface $latest_revision */
$latest_revision = $this->updateUtils
->getLatestRevision($this
->updateEntityType(), $entity_id);
// Check the latest revision was in the revisions sent to this function.
if (in_array($latest_revision
->getRevisionId(), $revision_ids)) {
$revisions[$entity_id] = $latest_revision;
}
}
return $revisions;
}
/**
* {@inheritdoc}
*/
public function validateConfigurationForm(array &$form, FormStateInterface $form_state) {
parent::validateConfigurationForm($form, $form_state);
/** @var ScheduledUpdateTypeInterface $scheduled_update_type */
$scheduled_update_type = $form_state
->get('scheduled_update_type');
// Check if entity type to be updated supports revisions.
if (!$this->updateUtils
->supportsRevisionUpdates($scheduled_update_type)) {
// @todo Check if any bundles in update entity type is moderated
$form_state
->setError($form['update_entity_type'], $this
->t('The latest revision runner cannot be used with an entity type that does not support revisions.'));
}
}
/**
* {@inheritdoc}
*/
public function getDescription() {
return $this
->t('Runs updates always against the latest revision of revisionable entities content.') . ' ' . t('This is useful for modules that allow forward revisioning such as Workbench Moderation.') . ' ' . t('This Update Runner can only be used with revisionable entity types.');
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
BaseUpdateRunner:: |
protected | property | ||
BaseUpdateRunner:: |
protected | property | @var \Drupal\Core\Entity\EntityTypeManagerInterface | |
BaseUpdateRunner:: |
protected | property | @var \Drupal\Core\Entity\EntityFieldManagerInterface | |
BaseUpdateRunner:: |
protected | property | The entity reference field ids target connected update types. | |
BaseUpdateRunner:: |
protected | property | If the runner is currently run by cron. | |
BaseUpdateRunner:: |
protected | property | If the runner is currently switched to a different user. | |
BaseUpdateRunner:: |
protected | property | Queue items that will be released after updates in queue are run. | |
BaseUpdateRunner:: |
protected | property | @var \Drupal\scheduled_updates\entity\ScheduledUpdateType | |
BaseUpdateRunner:: |
protected | property | ||
BaseUpdateRunner:: |
protected | function | Add conditions to a query to select updates to run. | |
BaseUpdateRunner:: |
protected | function | ||
BaseUpdateRunner:: |
public | function |
Add all updates to queue. Overrides UpdateRunnerInterface:: |
|
BaseUpdateRunner:: |
public | function |
Form constructor. Overrides PluginFormInterface:: |
1 |
BaseUpdateRunner:: |
public static | function |
Creates an instance of the plugin. Overrides ContainerFactoryPluginInterface:: |
|
BaseUpdateRunner:: |
protected | function | Display message about updates. | |
BaseUpdateRunner:: |
public | function | Get After Run behavior configuration. | |
BaseUpdateRunner:: |
public | function |
Get target entity ids for an entity reference field on a entity. Overrides UpdateRunnerInterface:: |
|
BaseUpdateRunner:: |
public | function |
Get how this runner should handle invalid entity updates. Overrides UpdateRunnerInterface:: |
|
BaseUpdateRunner:: |
public | function |
Get the Queue for this Update Runner. Overrides UpdateRunnerInterface:: |
|
BaseUpdateRunner:: |
protected | function | Get updates that are ready to be run for this Runner. | |
BaseUpdateRunner:: |
public | function |
Get all field ids that are attached to the entity type to be updated and
target this update type. Overrides UpdateRunnerInterface:: |
|
BaseUpdateRunner:: |
protected | function | Get Scheduled Update Type from the Form State. | |
BaseUpdateRunner:: |
public | function |
@inheritdoc Overrides UpdateRunnerInterface:: |
|
BaseUpdateRunner:: |
protected | function | Prepare an entity to be updated. | |
BaseUpdateRunner:: |
protected | function | ||
BaseUpdateRunner:: |
protected | function | Remove update from reference field value. | |
BaseUpdateRunner:: |
protected | function | Run an individual update from the queue. | |
BaseUpdateRunner:: |
public | function |
Run all updates that are in the queue. Overrides UpdateRunnerInterface:: |
|
BaseUpdateRunner:: |
protected | function | Set a entity to use a new revision is applicable. | |
BaseUpdateRunner:: |
public | function |
@inheritdoc Overrides UpdateRunnerInterface:: |
|
BaseUpdateRunner:: |
public | function |
Form submission handler. Overrides PluginFormInterface:: |
|
BaseUpdateRunner:: |
protected | function | Switch to another user to run an update if necessary. | |
BaseUpdateRunner:: |
protected | function | If the user has been switch to run an update switch the user back. | |
BaseUpdateRunner:: |
protected | function | Transfer field values from update to entity to be updated. | |
BaseUpdateRunner:: |
public | function |
Return the entity id of the entity type being updated. Overrides UpdateRunnerInterface:: |
|
BaseUpdateRunner:: |
public | function |
BaseUpdateRunner constructor. Overrides PluginBase:: |
|
ClassUtilsTrait:: |
protected | function | ||
ClassUtilsTrait:: |
protected | function | Determines if the class for an entity type definition implements and interface. | |
ClassUtilsTrait:: |
protected | function | ||
ClassUtilsTrait:: |
protected | function | ||
ClassUtilsTrait:: |
protected | function | Get the entity owner if applicable. | |
ClassUtilsTrait:: |
protected | function | Get the revision owner for an ContentEntity. | |
ClassUtilsTrait:: |
protected | function | Determines if an object or class name implements any interfaces in a list. | |
ClassUtilsTrait:: |
protected | function | Get class names of interfaces that support revision ownership. | |
ClassUtilsTrait:: |
protected | function | ||
ClassUtilsTrait:: |
protected | function | ||
ClassUtilsTrait:: |
public | function | ||
ClassUtilsTrait:: |
protected | function | ||
DependencySerializationTrait:: |
protected | property | An array of entity type IDs keyed by the property name of their storages. | |
DependencySerializationTrait:: |
protected | property | An array of service IDs keyed by property name used for serialization. | |
DependencySerializationTrait:: |
public | function | 1 | |
DependencySerializationTrait:: |
public | function | 2 | |
EmbeddedUpdateRunner:: |
protected | function | Deactivate any Scheduled Updates that are previous revision but not on current. | |
EmbeddedUpdateRunner:: |
protected | function |
Get all schedule updates for this types that should be added to queue. Overrides BaseUpdateRunner:: |
|
EmbeddedUpdateRunner:: |
protected | function | Return all schedule updates that are referenced via Entity Reference fields. | |
EmbeddedUpdateRunner:: |
protected | function | Get all previous revisions that have updates of the attached type. | |
EmbeddedUpdateRunner:: |
protected | function | Get all update ids for this connected Update type. | |
EmbeddedUpdateRunner:: |
public | function |
Fires when entity of type to be updated is changed. Overrides EntityMonitorUpdateRunnerInterface:: |
|
EmbeddedUpdateRunner:: |
protected | function | Reactive any updates that are on this entity that have been deactived previously. | |
LatestRevisionUpdateRunner:: |
public | function |
Get the description of the Runner Plugin. Overrides BaseUpdateRunner:: |
|
LatestRevisionUpdateRunner:: |
protected | function |
This method is overridden because the version in BaseUpdateRunner only needs
to get default revisions so does not call $query->allRevisions(). Overrides BaseUpdateRunner:: |
|
LatestRevisionUpdateRunner:: |
protected | function |
Load multi entities to update. Overrides BaseUpdateRunner:: |
|
LatestRevisionUpdateRunner:: |
public | function |
Form validation handler. Overrides BaseUpdateRunner:: |
|
MessengerTrait:: |
protected | property | The messenger. | 29 |
MessengerTrait:: |
public | function | Gets the messenger. | 29 |
MessengerTrait:: |
public | function | Sets the messenger. | |
PluginBase:: |
protected | property | Configuration information passed into the plugin. | 1 |
PluginBase:: |
protected | property | The plugin implementation definition. | 1 |
PluginBase:: |
protected | property | The plugin_id. | |
PluginBase:: |
constant | A string which is used to separate base plugin IDs from the derivative ID. | ||
PluginBase:: |
public | function |
Gets the base_plugin_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the derivative_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the definition of the plugin implementation. Overrides PluginInspectionInterface:: |
3 |
PluginBase:: |
public | function |
Gets the plugin_id of the plugin instance. Overrides PluginInspectionInterface:: |
|
PluginBase:: |
public | function | Determines if the plugin is configurable. | |
StringTranslationTrait:: |
protected | property | The string translation service. | 1 |
StringTranslationTrait:: |
protected | function | Formats a string containing a count of items. | |
StringTranslationTrait:: |
protected | function | Returns the number of plurals supported by a given language. | |
StringTranslationTrait:: |
protected | function | Gets the string translation service. | |
StringTranslationTrait:: |
public | function | Sets the string translation service to use. | 2 |
StringTranslationTrait:: |
protected | function | Translates a string to the current language or to a given language. | |
UpdateRunnerInterface:: |
constant | |||
UpdateRunnerInterface:: |
constant | |||
UpdateRunnerInterface:: |
constant | |||
UpdateRunnerInterface:: |
constant | |||
UpdateRunnerInterface:: |
constant | |||
UpdateRunnerInterface:: |
constant | |||
UpdateRunnerInterface:: |
constant | |||
UpdateRunnerInterface:: |
constant | |||
UpdateRunnerInterface:: |
constant | |||
UpdateRunnerInterface:: |
constant | |||
UpdateRunnerInterface:: |
constant | |||
UpdateRunnerInterface:: |
constant |