public function EventSubscriber::apiTestMediaPrePublish in Scheduler 2.x
Operations to perform before Scheduler publishes a media item.
Parameters
\Drupal\scheduler\Event\SchedulerEvent $event: The scheduler event.
File
- tests/
modules/ scheduler_api_test/ src/ EventSubscriber.php, line 174
Class
- EventSubscriber
- Tests events fired on entity objects.
Namespace
Drupal\scheduler_api_testCode
public function apiTestMediaPrePublish(SchedulerEvent $event) {
$entity = $event
->getEntity();
if (!$entity
->isPublished() && strpos($entity
->label(), 'API TEST MEDIA') === 0) {
// Media entities do not have the 'sticky' and 'promote' fields. Instead
// we can alter the name, for checking in the test.
$entity
->setName('API TEST MEDIA - changed by "PRE_PUBLISH" event');
$event
->setEntity($entity);
}
}