diff --git a/src/Core/ConditionManager.php b/src/Core/ConditionManager.php index a38573bb..ce7519aa 100644 --- a/src/Core/ConditionManager.php +++ b/src/Core/ConditionManager.php @@ -42,22 +42,9 @@ class ConditionManager extends CoreConditionManager { // Make sure that all definitions have a category to avoid PHP notices in // CategorizingPluginManagerTrait. // @todo Fix this in core in CategorizingPluginManagerTrait. - foreach ($definitions as $key => &$definition) { + foreach ($definitions as &$definition) { if (!isset($definition['category'])) { $definition['category'] = $this->t('Other'); - // @todo Remove the unset() when core conditions can work as - // Rules conditions. - // - // @see https://www.drupal.org/project/rules/issues/2927132 - // - // Because core Conditions do not currently define some context values - // required by Rules, we need to make sure they can't be selected - // through the Rules UI. To do this, we make use of the fact that none - // of the core Conditions make use of the concept of 'category' as - // defined by the CategorizingPluginManager. Thus, we assume that any - // condition without a 'category' is a core Condition and we remove it - // from list of plugin definitions used by the Rules UI. - unset($definitions[$key]); } } return $definitions; diff --git a/src/Form/Expression/ConditionForm.php b/src/Form/Expression/ConditionForm.php index 95e7ecd1..ab0db0fb 100644 --- a/src/Form/Expression/ConditionForm.php +++ b/src/Form/Expression/ConditionForm.php @@ -57,7 +57,16 @@ class ConditionForm implements ExpressionFormInterface { $options = []; foreach ($condition_definitions as $group => $definitions) { foreach ($definitions as $id => $definition) { - $options[$group][$id] = $definition['label']; + if ($group != $this->t('Other')) { + // Because core Conditions do not currently define some context + // values required by Rules, we need to make sure they can't be + // selected through the Rules UI. The Rules ConditionManager puts + // these core Conditions into the 'Other' group so that we can + // identify them and leave them off of the Condition selection + // form element below. + // @see https://www.drupal.org/project/rules/issues/2927132 + $options[$group][$id] = $definition['label']; + } } }