Skip to content
Snippets Groups Projects
Commit 2276f561 authored by Jonathan Smith's avatar Jonathan Smith Committed by Jonathan Smith
Browse files

Issue #3224263 by jonathan1055: Add $entityTypeObject property and...

Issue #3224263 by jonathan1055:  Add $entityTypeObject property and entityTypeObject() method in plugin
parent e5cf067c
No related branches found
Tags 2.0.0-rc8
No related merge requests found
......@@ -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();
......
......@@ -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);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment