Skip to content
Snippets Groups Projects

Issue #3230463: Let other modules alter the list of available condition plugins

1 file
+ 8
3
Compare changes
  • Side-by-side
  • Inline
@@ -2,7 +2,7 @@
@@ -2,7 +2,7 @@
namespace Drupal\ctools\Form;
namespace Drupal\ctools\Form;
use Drupal\Component\Plugin\PluginManagerInterface;
use Drupal\Core\Plugin\FilteredPluginManagerInterface;
use Drupal\Component\Serialization\Json;
use Drupal\Component\Serialization\Json;
use Drupal\Core\Ajax\AjaxResponse;
use Drupal\Core\Ajax\AjaxResponse;
use Drupal\Core\Ajax\OpenModalDialogCommand;
use Drupal\Core\Ajax\OpenModalDialogCommand;
@@ -41,7 +41,7 @@ abstract class ManageConditions extends FormBase {
@@ -41,7 +41,7 @@ abstract class ManageConditions extends FormBase {
}
}
public function __construct(PluginManagerInterface $manager, FormBuilderInterface $form_builder) {
public function __construct(FilteredPluginManagerInterface $manager, FormBuilderInterface $form_builder) {
$this->manager = $manager;
$this->manager = $manager;
$this->formBuilder = $form_builder;
$this->formBuilder = $form_builder;
}
}
@@ -62,7 +62,12 @@ abstract class ManageConditions extends FormBase {
@@ -62,7 +62,12 @@ abstract class ManageConditions extends FormBase {
$form['#attached']['library'][] = 'core/drupal.dialog.ajax';
$form['#attached']['library'][] = 'core/drupal.dialog.ajax';
$options = [];
$options = [];
$contexts = $this->getContexts($cached_values);
$contexts = $this->getContexts($cached_values);
foreach ($this->manager->getDefinitionsForContexts($contexts) as $plugin_id => $definition) {
$condition_definitions = $this->manager
 
->getFilteredDefinitions($this->getFormId(), $contexts, [
 
'form_object' => $this,
 
'form_state' => $form_state,
 
]);
 
foreach ($condition_definitions as $plugin_id => $definition) {
$options[$plugin_id] = (string) $definition['label'];
$options[$plugin_id] = (string) $definition['label'];
}
}
$form['items'] = [
$form['items'] = [
Loading