ExcludeContentFieldBase.php in Acquia Content Hub 8.2
File
src/EventSubscriber/ExcludeContentField/ExcludeContentFieldBase.php
View source
<?php
namespace Drupal\acquia_contenthub\EventSubscriber\ExcludeContentField;
use Drupal\acquia_contenthub\AcquiaContentHubEvents;
use Drupal\acquia_contenthub\Event\ExcludeEntityFieldEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
abstract class ExcludeContentFieldBase implements EventSubscriberInterface {
public static $priority = 0;
public static function getSubscribedEvents() {
$events[AcquiaContentHubEvents::EXCLUDE_CONTENT_ENTITY_FIELD][] = [
'excludeContentField',
self::$priority,
];
return $events;
}
public abstract function shouldExclude(ExcludeEntityFieldEvent $event) : bool;
public function excludeContentField(ExcludeEntityFieldEvent $event) {
if ($this
->shouldExclude($event)) {
$event
->exclude();
$event
->stopPropagation();
}
}
}