Loading ctools.module +12 −0 Original line number Diff line number Diff line <?php use Drupal\Core\Entity\Plugin\Condition\EntityBundle as CoreEntityBundle; use Drupal\ctools\Plugin\Condition\EntityBundle; /** * @file * Provides utility and helper APIs for Drupal developers and site builders. Loading Loading @@ -91,6 +94,15 @@ function ctools_condition_info_alter(&$definitions) { if (isset($definitions['node_type']) && $definitions['node_type']['class'] == 'Drupal\node\Plugin\Condition\NodeType') { $definitions['node_type']['class'] = 'Drupal\ctools\Plugin\Condition\NodeType'; } // Replace all generic entity bundle conditions classes if they are unaltered, // these exist in Drupal 9.3+. foreach ($definitions as $id => $definition) { if (strpos($id, 'entity_bundle:') === 0 && $definition['class'] == CoreEntityBundle::class) { $definitions[$id]['class'] = EntityBundle::class; } } } Loading src/Plugin/Condition/EntityBundle.php +1 −0 Original line number Diff line number Diff line Loading @@ -9,6 +9,7 @@ use Drupal\Core\Entity\ContentEntityInterface; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Plugin\ContainerFactoryPluginInterface; use Drupal\ctools\ConstraintConditionInterface; use \Drupal\Core\Entity\Plugin\Condition\EntityBundle as CoreEntityBundle; use Symfony\Component\DependencyInjection\ContainerInterface; /** Loading src/Plugin/Deriver/EntityBundle.php +7 −0 Original line number Diff line number Diff line Loading @@ -13,6 +13,13 @@ class EntityBundle extends EntityDeriverBase { * {@inheritdoc} */ public function getDerivativeDefinitions($base_plugin_definition) { // Do not define any derivatives on Drupal 9.3+, instead, replace the core // class in ctools_condition_info_alter(). if (\version_compare(\Drupal::VERSION, '9.3', '>')) { return []; } foreach ($this->entityTypeManager->getDefinitions() as $entity_type_id => $entity_type) { if ($entity_type->hasKey('bundle')) { $this->derivatives[$entity_type_id] = $base_plugin_definition; Loading Loading
ctools.module +12 −0 Original line number Diff line number Diff line <?php use Drupal\Core\Entity\Plugin\Condition\EntityBundle as CoreEntityBundle; use Drupal\ctools\Plugin\Condition\EntityBundle; /** * @file * Provides utility and helper APIs for Drupal developers and site builders. Loading Loading @@ -91,6 +94,15 @@ function ctools_condition_info_alter(&$definitions) { if (isset($definitions['node_type']) && $definitions['node_type']['class'] == 'Drupal\node\Plugin\Condition\NodeType') { $definitions['node_type']['class'] = 'Drupal\ctools\Plugin\Condition\NodeType'; } // Replace all generic entity bundle conditions classes if they are unaltered, // these exist in Drupal 9.3+. foreach ($definitions as $id => $definition) { if (strpos($id, 'entity_bundle:') === 0 && $definition['class'] == CoreEntityBundle::class) { $definitions[$id]['class'] = EntityBundle::class; } } } Loading
src/Plugin/Condition/EntityBundle.php +1 −0 Original line number Diff line number Diff line Loading @@ -9,6 +9,7 @@ use Drupal\Core\Entity\ContentEntityInterface; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Plugin\ContainerFactoryPluginInterface; use Drupal\ctools\ConstraintConditionInterface; use \Drupal\Core\Entity\Plugin\Condition\EntityBundle as CoreEntityBundle; use Symfony\Component\DependencyInjection\ContainerInterface; /** Loading
src/Plugin/Deriver/EntityBundle.php +7 −0 Original line number Diff line number Diff line Loading @@ -13,6 +13,13 @@ class EntityBundle extends EntityDeriverBase { * {@inheritdoc} */ public function getDerivativeDefinitions($base_plugin_definition) { // Do not define any derivatives on Drupal 9.3+, instead, replace the core // class in ctools_condition_info_alter(). if (\version_compare(\Drupal::VERSION, '9.3', '>')) { return []; } foreach ($this->entityTypeManager->getDefinitions() as $entity_type_id => $entity_type) { if ($entity_type->hasKey('bundle')) { $this->derivatives[$entity_type_id] = $base_plugin_definition; Loading