From 40918cb2d3f53743c1c61272992250647f40af91 Mon Sep 17 00:00:00 2001 From: Alan Stanley Date: Fri, 3 Jan 2020 09:49:02 -0400 Subject: [PATCH] added filter --- .../ContextReaction/DerivativeReaction.php | 30 ++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/src/Plugin/ContextReaction/DerivativeReaction.php b/src/Plugin/ContextReaction/DerivativeReaction.php index 7ddaed4f..f953c024 100644 --- a/src/Plugin/ContextReaction/DerivativeReaction.php +++ b/src/Plugin/ContextReaction/DerivativeReaction.php @@ -2,6 +2,8 @@ namespace Drupal\islandora\Plugin\ContextReaction; +use Drupal\Core\Form\FormStateInterface; +use Drupal\islandora\Plugin\Action\AbstractGenerateDerivative; use Drupal\islandora\PresetReaction\PresetReaction; /** @@ -12,4 +14,30 @@ use Drupal\islandora\PresetReaction\PresetReaction; * label = @Translation("Derivative") * ) */ -class DerivativeReaction extends PresetReaction {} +class DerivativeReaction extends PresetReaction { + + /** + * {@inheritdoc} + */ + public function buildConfigurationForm(array $form, FormStateInterface $form_state) { + $actions = $this->actionStorage->loadMultiple(); + foreach ($actions as $action) { + $plugin = $action->getPlugin(); + if ($plugin instanceof AbstractGenerateDerivative) { + $options[ucfirst($action->getType())][$action->id()] = $action->label(); + } + } + $config = $this->getConfiguration(); + $form['actions'] = [ + '#title' => $this->t('Actions'), + '#description' => $this->t('Pre-configured actions to execute. Multiple actions may be selected by shift or ctrl clicking.'), + '#type' => 'select', + '#multiple' => TRUE, + '#options' => $options, + '#default_value' => isset($config['actions']) ? $config['actions'] : '', + '#size' => 15, + ]; + + return $form; + } +}