You are here

public function TestContinuousEventSubscriber::onShouldCreateJob in Translation Management Tool 8

Do not add the job if we have a filter match.

Parameters

\Drupal\tmgmt\Events\ShouldCreateJobEvent $event: The event object.

File

tmgmt_test/src/EventSubscriber/TestContinuousEventSubscriber.php, line 41

Class

TestContinuousEventSubscriber
Test event subscriber to test the continuous jobs events.

Namespace

Drupal\tmgmt_test\EventSubscriber

Code

public function onShouldCreateJob(ShouldCreateJobEvent $event) {

  // Filter out content.
  if ($event
    ->getPlugin() === 'content') {
    $storage = $this->entityTypeManager
      ->getStorage($event
      ->getItemType());
    $entity = $storage
      ->load($event
      ->getItemId());
    if ($entity
      ->label() === static::DISALLOWED_LABEL) {
      $event
        ->setShouldCreateItem(FALSE);
    }
  }
}