You are here

public function Simple::onQueuePostSave in Entityqueue 8

Acts on an entity queue before the insert or update hook is invoked.

Parameters

\Drupal\entityqueue\EntityQueueInterface $queue: The entity queue object.

\Drupal\Core\Entity\EntityStorageInterface $storage: The entity storage object.

bool $update: TRUE if the queue has been updated, or FALSE if it has been inserted.

Overrides EntityQueueHandlerBase::onQueuePostSave

File

src/Plugin/EntityQueueHandler/Simple.php, line 119

Class

Simple
Defines an entity queue handler that manages a single subqueue.

Namespace

Drupal\entityqueue\Plugin\EntityQueueHandler

Code

public function onQueuePostSave(EntityQueueInterface $queue, EntityStorageInterface $storage, $update = TRUE) {

  // Make sure that every simple queue has a subqueue.
  if ($update) {
    $subqueue = EntitySubqueue::load($queue
      ->id());
    $subqueue
      ->setTitle($queue
      ->label());
  }
  else {
    $subqueue = EntitySubqueue::create([
      'queue' => $queue
        ->id(),
      'name' => $queue
        ->id(),
      'title' => $queue
        ->label(),
      'langcode' => $queue
        ->language()
        ->getId(),
    ]);
  }
  $subqueue
    ->save();
}