You are here

class PublisherSubscriberStatusCdfAttribute in Acquia Content Hub 8.2

Extracts user specific data for identifying duplicate and anonymous users.

Hierarchy

Expanded class hierarchy of PublisherSubscriberStatusCdfAttribute

1 file declares its use of PublisherSubscriberStatusCdfAttribute
PublisherSubscriberStatusCdfAttributeTest.php in tests/src/Unit/EventSubscriber/CdfAttributes/PublisherSubscriberStatusCdfAttributeTest.php
1 string reference to 'PublisherSubscriberStatusCdfAttribute'
acquia_contenthub.services.yml in ./acquia_contenthub.services.yml
acquia_contenthub.services.yml
1 service uses PublisherSubscriberStatusCdfAttribute
entity.publisher.subscriber.status.cdf.attribute in ./acquia_contenthub.services.yml
Drupal\acquia_contenthub\EventSubscriber\CdfAttributes\PublisherSubscriberStatusCdfAttribute

File

src/EventSubscriber/CdfAttributes/PublisherSubscriberStatusCdfAttribute.php, line 14

Namespace

Drupal\acquia_contenthub\EventSubscriber\CdfAttributes
View source
class PublisherSubscriberStatusCdfAttribute implements EventSubscriberInterface {

  /**
   * Status Checker.
   *
   * @var \Drupal\acquia_contenthub\PubSubModuleStatusChecker
   */
  private $checker;

  /**
   * Constructor.
   *
   * @param \Drupal\acquia_contenthub\PubSubModuleStatusChecker $checker
   *   Status Checker.
   */
  public function __construct(PubSubModuleStatusChecker $checker) {
    $this->checker = $checker;
  }

  /**
   * {@inheritdoc}
   */
  public static function getSubscribedEvents() {
    $events[AcquiaContentHubEvents::BUILD_CLIENT_CDF][] = [
      'onBuildClientCdf',
      100,
    ];
    return $events;
  }

  /**
   * Method called on the BUILD_CLIENT_CDF event.
   *
   * Adds publisher/subscriber status to the cdf.
   *
   * @param \Drupal\acquia_contenthub\Event\BuildClientCdfEvent $event
   *   The BuildClientCdfEvent object.
   *
   * @throws \Exception
   */
  public function onBuildClientCdf(BuildClientCdfEvent $event) {
    $cdf = $event
      ->getCdf();
    $cdf
      ->addAttribute('publisher', CDFAttribute::TYPE_BOOLEAN, $this->checker
      ->isPublisher());
    $cdf
      ->addAttribute('subscriber', CDFAttribute::TYPE_BOOLEAN, $this->checker
      ->isSubscriber());
  }

}

Members

Namesort descending Modifiers Type Description Overrides
PublisherSubscriberStatusCdfAttribute::$checker private property Status Checker.
PublisherSubscriberStatusCdfAttribute::getSubscribedEvents public static function Returns an array of event names this subscriber wants to listen to.
PublisherSubscriberStatusCdfAttribute::onBuildClientCdf public function Method called on the BUILD_CLIENT_CDF event.
PublisherSubscriberStatusCdfAttribute::__construct public function Constructor.