Skip to content
Snippets Groups Projects

Issue #3363972 by jurgenhaas: Support for ECA

Open Jürgen Haas requested to merge issue/scheduler-3363972:3363972-support-for-eca into 2.x
3 unresolved threads

Closes #3363972

Merge request reports

Members who can merge are allowed to add commits.
Approval is optional
Code Quality is loading
Test summary results are being parsed
Merge blocked: 1 check failed
Merge conflicts must be resolved.

Merge details

  • The source branch is 5 commits behind the target branch.
  • 1 commit will be added to 2.x.
  • Source branch will not be deleted.

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
43 public function evaluate(): bool {
44 $entity = $this->getValueFromContext('entity');
45
46 if (!isset($entity->original) || !$this->schedulerManager->getPlugin($entity->getEntityTypeId())) {
47 return FALSE;
48 }
49
50 $publish_on_original = !empty($entity->original->publish_on->value ?? NULL);
51 $publish_on = empty($entity->publish_on->value ?? NULL);
52 $published_original = $entity->original->status->value ?? FALSE;
53 $published = $entity->status->value ?? FALSE;
54
55 return $this->negationCheck($publish_on_original)
56 && $this->negationCheck($publish_on)
57 && !$published_original
58 && $published;
  • Comment on lines +46 to +58

    This shouldn't be done that way. The evaluate method needs to determine, if the condition is TRUE or FALSE, and then finally return the negation check with that result. I guess, something like this:

    Suggested change
    46 if (!isset($entity->original) || !$this->schedulerManager->getPlugin($entity->getEntityTypeId())) {
    47 return FALSE;
    48 }
    49
    50 $publish_on_original = !empty($entity->original->publish_on->value ?? NULL);
    51 $publish_on = empty($entity->publish_on->value ?? NULL);
    52 $published_original = $entity->original->status->value ?? FALSE;
    53 $published = $entity->status->value ?? FALSE;
    54
    55 return $this->negationCheck($publish_on_original)
    56 && $this->negationCheck($publish_on)
    57 && !$published_original
    58 && $published;
    46 if (!isset($entity->original) || !$this->schedulerManager->getPlugin($entity->getEntityTypeId())) {
    47 $result = FALSE;
    48 }
    49 else {
    50 $publish_on_original = !empty($entity->original->publish_on->value ?? NULL);
    51 $publish_on = empty($entity->publish_on->value ?? NULL);
    52 $published_original = $entity->original->status->value ?? FALSE;
    53 $published = $entity->status->value ?? FALSE;
    54 $result = $publish_on_original && $publish_on;
    55 }
    56 return $this->negationCheck($result);
  • Darko Hrgovic changed this line in version 10 of the diff

    changed this line in version 10 of the diff

  • Please register or sign in to reply
  • 43 public function evaluate(): bool {
    44 $entity = $this->getValueFromContext('entity');
    45
    46 if (!isset($entity->original) || !$this->schedulerManager->getPlugin($entity->getEntityTypeId())) {
    47 return FALSE;
    48 }
    49
    50 $unpublish_on_original = !empty($entity->original->unpublish_on->value ?? NULL);
    51 $unpublish_on = empty($entity->unpublish_on->value ?? NULL);
    52 $published_original = $entity->original->status->value ?? FALSE;
    53 $published = $entity->status->value ?? FALSE;
    54
    55 return $this->negationCheck($unpublish_on_original)
    56 && $this->negationCheck($unpublish_on)
    57 && $published_original
    58 && !$published;
  • 7 use Symfony\Component\DependencyInjection\ContainerInterface;
    8
    9 /**
    10 * Plugin of the ECA condition "Unpublish triggered by scheduler".
    11 *
    12 * @EcaCondition(
    13 * id = "scheduler_unpublish_triggered_by_scheduler",
    14 * label = @Translation("Unpublish triggered by scheduler"),
    15 * description = @Translation("This condition determines if the last unpublish of the entity was triggered by the scheduler."),
    16 * eca_version_introduced = "2.2.2",
    17 * context_definitions = {
    18 * "entity" = @ContextDefinition("entity", label = @Translation("Entity"))
    19 * }
    20 * )
    21 */
    22 class UnpublishTriggeredByScheduler extends ConditionBase {
  • Darko Hrgovic added 1 commit

    added 1 commit

    • 67758912 - Refactored for proper use of negationCheck().

    Compare with previous version

  • Refactored for proper use of negationCheck() and unpublished plugin extends the published plugin.

  • Please register or sign in to reply
    Loading