diff --git a/src/SchedulerManager.php b/src/SchedulerManager.php index 05551a4a225b9f1c41fc0838c592a6e6b37e04e8..cfda7e9bfea2b490082b75a1f0cf9c2a7fd3e17b 100644 --- a/src/SchedulerManager.php +++ b/src/SchedulerManager.php @@ -253,7 +253,7 @@ class SchedulerManager { $query->accessCheck(FALSE); // If the entity type is revisionable then make sure we look for the // latest revision. This is important for moderated entities. - if ($this->entityTypeManager->getDefinition($entityTypeId)->isRevisionable()) { + if ($plugin->entityTypeObject()->isRevisionable()) { $query->latestRevision(); } $ids = $query->execute(); @@ -474,7 +474,7 @@ class SchedulerManager { $query->accessCheck(FALSE); // If the entity type is revisionable then make sure we look for the // latest revision. This is important for moderated entities. - if ($this->entityTypeManager->getDefinition($entityTypeId)->isRevisionable()) { + if ($plugin->entityTypeObject()->isRevisionable()) { $query->latestRevision(); } $ids = $query->execute(); diff --git a/src/SchedulerPluginBase.php b/src/SchedulerPluginBase.php index 20377bebacd492dddfc79180eb61e9311e703d6b..fb5ca8facda06b49450f85374fc5f0ef9e9ba0a8 100644 --- a/src/SchedulerPluginBase.php +++ b/src/SchedulerPluginBase.php @@ -18,6 +18,13 @@ abstract class SchedulerPluginBase extends PluginBase implements SchedulerPlugin */ protected $entityTypeManager; + /** + * The entity type object for this plugin. + * + * @var Drupal\Core\Config\Entity\ConfigEntityType + */ + protected $entityTypeObject; + /** * A static cache of create/edit entity form IDs. * @@ -38,6 +45,8 @@ abstract class SchedulerPluginBase extends PluginBase implements SchedulerPlugin public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) { $instance = new static($configuration, $plugin_id, $plugin_definition); $instance->entityTypeManager = $container->get('entity_type.manager'); + $instance->entityTypeObject = $instance->entityTypeManager + ->getDefinition($plugin_definition['entityType']); return $instance; } @@ -71,6 +80,16 @@ abstract class SchedulerPluginBase extends PluginBase implements SchedulerPlugin return $this->pluginDefinition['entityType']; } + /** + * Get the entity type object supported by this plugin. + * + * @return Drupal\Core\Config\Entity\ConfigEntityType + * The entity type object. + */ + public function entityTypeObject() { + return $this->entityTypeObject; + } + /** * Get module dependency. * @@ -160,9 +179,7 @@ abstract class SchedulerPluginBase extends PluginBase implements SchedulerPlugin * The name of the type/bundle field for this entity type. */ public function typeFieldName() { - return $this->entityTypeManager - ->getDefinition($this->entityType()) - ->getKey('bundle'); + return $this->entityTypeObject->getKey('bundle'); } /** @@ -172,12 +189,10 @@ abstract class SchedulerPluginBase extends PluginBase implements SchedulerPlugin * The type/bundle objects, keyed by type/bundle name. */ public function getTypes() { - $bundleDefinition = $this->entityTypeManager - ->getDefinition($this->entityType()) - ->getBundleEntityType(); + $bundleEntityType = $this->entityTypeObject->getBundleEntityType(); return $this->entityTypeManager - ->getStorage($bundleDefinition) + ->getStorage($bundleEntityType) ->loadMultiple(); } @@ -200,9 +215,7 @@ abstract class SchedulerPluginBase extends PluginBase implements SchedulerPlugin return $this->entityTypeFormIds; } - $bundleEntityType = $this->entityTypeManager - ->getDefinition($this->entityType()) - ->getBundleEntityType(); + $bundleEntityType = $this->entityTypeObject->getBundleEntityType(); return $this->entityTypeFormIds = $this->entityFormIdsByType($bundleEntityType, TRUE); }