Skip to content
Snippets Groups Projects
Commit 94051139 authored by mxh's avatar mxh
Browse files

Issue #3291737 by mxh: Adjust event implementations to new version of ECA

parent 59567890
No related branches found
No related tags found
No related merge requests found
...@@ -4,13 +4,13 @@ namespace Drupal\eca_vbo\Event; ...@@ -4,13 +4,13 @@ namespace Drupal\eca_vbo\Event;
use Drupal\Core\Action\ActionInterface; use Drupal\Core\Action\ActionInterface;
use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\EntityInterface;
use Drupal\eca\Event\ContentEntityEventInterface; use Drupal\eca\Event\EntityEventInterface;
use Drupal\views\ViewExecutable; use Drupal\views\ViewExecutable;
/** /**
* Dispatches when executing a "eca_vbo_execute" action. * Dispatches when executing a "eca_vbo_execute" action.
*/ */
class VboExecuteEvent extends VboEventBase implements ContentEntityEventInterface { class VboExecuteEvent extends VboEventBase implements EntityEventInterface {
/** /**
* The main entity of the Views row. * The main entity of the Views row.
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
namespace Drupal\eca_vbo\Plugin\ECA\Event; namespace Drupal\eca_vbo\Plugin\ECA\Event;
use Drupal\Core\Form\FormStateInterface;
use Drupal\eca\Entity\Objects\EcaEvent; use Drupal\eca\Entity\Objects\EcaEvent;
use Drupal\eca\Event\Tag; use Drupal\eca\Event\Tag;
use Drupal\eca\Plugin\ECA\Event\EventBase; use Drupal\eca\Plugin\ECA\Event\EventBase;
...@@ -63,35 +64,58 @@ class VboEvent extends EventBase { ...@@ -63,35 +64,58 @@ class VboEvent extends EventBase {
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function fields(): array { public function defaultConfiguration(): array {
$fields = []; return [
$fields[] = [ 'operation_name' => '',
'name' => 'operation_name', 'view_id' => '',
'label' => 'Operation name', 'display_id' => '',
'type' => 'String', ];
'description' => '', }
/**
* {@inheritdoc}
*/
public function buildConfigurationForm(array $form, FormStateInterface $form_state): array {
$form['operation_name'] = [
'#type' => 'textfield',
'#title' => $this->t('Operation name'),
'#default_value' => $this->configuration['operation_name'],
'#required' => TRUE,
'#weight' => 10,
]; ];
end($fields);
$field = &$fields[key($fields)];
if ($this->eventClass() === VboExecuteEvent::class) { if ($this->eventClass() === VboExecuteEvent::class) {
$field['description'] = 'The operation name identifies this process and will show up in the bulk operations configuration form as selectable action. If you need custom access handling using the operation name, then make sure that the Views configuration is using the <em>ECA bulk operations</em> Views field plugin.'; $form['operation_name']['#description'] = $this->t('The operation name identifies this process and will show up in the bulk operations configuration form as selectable action. If you need custom access handling using the operation name, then make sure that the Views configuration is using the <em>ECA bulk operations</em> Views field plugin.');
} }
elseif ($this->eventClass() === VboCustomAccessEvent::class) { elseif ($this->eventClass() === VboCustomAccessEvent::class) {
$field['description'] = 'Important note: The operation name is only available, when the operation got executed from the <em>ECA bulk operations</em> Views field plugin.'; $form['operation_name']['#description'] = $this->t('Important note: The operation name is only available, when the operation got executed from the <em>ECA bulk operations</em> Views field plugin.');
} }
$fields[] = [
'name' => 'view_id', $form['view_id'] = [
'label' => 'Restrict by view ID', '#type' => 'textfield',
'type' => 'String', '#title' => $this->t('Restrict by view ID'),
'description' => '', '#default_value' => $this->configuration['view_id'],
'#required' => TRUE,
'#weight' => 20,
]; ];
$fields[] = [
'name' => 'display_id', $form['display_id'] = [
'label' => 'Restrict by view display ID', '#type' => 'textfield',
'type' => 'String', '#title' => $this->t('Restrict by view display ID'),
'description' => '', '#default_value' => $this->configuration['display_id'],
'#required' => TRUE,
'#weight' => 30,
]; ];
return $fields;
return $form;
}
/**
* {@inheritdoc}
*/
public function submitConfigurationForm(array &$form, FormStateInterface $form_state): void {
$this->configuration['operation_name'] = $form_state->getValue('operation_name');
$this->configuration['view_id'] = $form_state->getValue('view_id');
$this->configuration['display_id'] = $form_state->getValue('display_id');
} }
/** /**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment