Skip to content
Snippets Groups Projects
Commit 9685d24c authored by Jürgen Haas's avatar Jürgen Haas
Browse files

Issue #3278067 by jurgenhaas: eca_trigger_content_entity_custom_event should...

Issue #3278067 by jurgenhaas: eca_trigger_content_entity_custom_event should handle entity being NULL
parent 95184af0
No related merge requests found
......@@ -2,8 +2,10 @@
namespace Drupal\eca_content\Plugin\Action;
use Drupal\Core\Access\AccessResult;
use Drupal\Core\Entity\ContentEntityInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Session\AccountInterface;
use Drupal\eca\Plugin\Action\ConfigurableActionBase;
use Drupal\eca_content\Event\ContentEntityCustomEvent;
use Drupal\eca_content\Event\ContentEntityEvents;
......@@ -49,10 +51,18 @@ class TriggerContentEntityCustomEvent extends ConfigurableActionBase {
/**
* {@inheritdoc}
*/
public function execute($entity = NULL): void {
if (!($entity instanceof ContentEntityInterface)) {
throw new \InvalidArgumentException('No content entity provided.');
public function access($object, AccountInterface $account = NULL, $return_as_object = FALSE) {
if (!($object instanceof ContentEntityInterface)) {
$result = AccessResult::forbidden();
return $return_as_object ? $result : $result->isAllowed();
}
return parent::access($object, $account, $return_as_object);
}
/**
* {@inheritdoc}
*/
public function execute($entity = NULL): void {
$event_id = $this->tokenServices->replaceClear($this->configuration['event_id']);
$event = new ContentEntityCustomEvent($entity, $this->entityTypes, $event_id, ['event' => $this->event]);
$event->addTokenNamesFromString($this->configuration['tokens']);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment