class IsNotParagraph in Acquia Content Hub 8.2
Subscribes to entity eligibility to prevent enqueueing paragraphs.
Hierarchy
- class \Drupal\acquia_contenthub_publisher\EventSubscriber\EnqueueEligibility\IsNotParagraph implements \Symfony\Component\EventDispatcher\EventSubscriberInterface
Expanded class hierarchy of IsNotParagraph
1 file declares its use of IsNotParagraph
- IsNotParagraphTest.php in modules/
acquia_contenthub_publisher/ tests/ src/ Unit/ EventSubscriber/ EntityEligibility/ IsNotParagraphTest.php
1 string reference to 'IsNotParagraph'
- acquia_contenthub_publisher.services.yml in modules/
acquia_contenthub_publisher/ acquia_contenthub_publisher.services.yml - modules/acquia_contenthub_publisher/acquia_contenthub_publisher.services.yml
1 service uses IsNotParagraph
- content_paragraph.enqueue in modules/
acquia_contenthub_publisher/ acquia_contenthub_publisher.services.yml - Drupal\acquia_contenthub_publisher\EventSubscriber\EnqueueEligibility\IsNotParagraph
File
- modules/
acquia_contenthub_publisher/ src/ EventSubscriber/ EnqueueEligibility/ IsNotParagraph.php, line 13
Namespace
Drupal\acquia_contenthub_publisher\EventSubscriber\EnqueueEligibilityView source
class IsNotParagraph implements EventSubscriberInterface {
/**
* {@inheritdoc}
*/
public static function getSubscribedEvents() {
$events[ContentHubPublisherEvents::ENQUEUE_CANDIDATE_ENTITY][] = [
'onEnqueueCandidateEntity',
50,
];
return $events;
}
/**
* Prevent paragraphs from enqueueing.
*
* @param \Drupal\acquia_contenthub_publisher\Event\ContentHubEntityEligibilityEvent $event
* The event to determine entity eligibility.
*
* @throws \Exception
*/
public function onEnqueueCandidateEntity(ContentHubEntityEligibilityEvent $event) {
// Never export Paragraph entities as main entities.
// They should only be exported as dependencies.
$entity = $event
->getEntity();
if ($entity instanceof ParagraphInterface) {
$event
->setEligibility(FALSE);
$event
->stopPropagation();
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
IsNotParagraph:: |
public static | function | Returns an array of event names this subscriber wants to listen to. | |
IsNotParagraph:: |
public | function | Prevent paragraphs from enqueueing. |