You are here

class SocialMediaSubscriber in Social media share 8

Listens to the dynamic route events.

Hierarchy

  • class \Drupal\social_media\EventSubscriber\SocialMediaSubscriber implements \Symfony\Component\EventDispatcher\EventSubscriberInterface

Expanded class hierarchy of SocialMediaSubscriber

File

./social_media.api.php, line 10

Namespace

Drupal\social_media\EventSubscriber
View source
class SocialMediaSubscriber implements EventSubscriberInterface {

  /**
   * Public static method used by Drupals event.
   *
   * @return mixed
   *   Array of events we subscribe to.
   */
  public static function getSubscribedEvents() {
    $events = [];
    $events['social_media.add_more_social_media'][] = [
      'addMoreSocialMedia',
      39,
    ];
    $events['social_media.pre_execute'][] = [
      'executeSocialMedia',
      39,
    ];
    $events['social_media.pre_render'][] = [
      'renderSocialMedia',
      39,
    ];
    return $events;
  }

  /**
   * Subscribes to  social_media.add_more_social_media event.
   */
  public function addMoreSocialMedia($event) {
    $element = $event
      ->getElement();
    $element['google_plus'] = 'Google plus';
    $event
      ->setElement($element);
  }

  /**
   * Subscribes to social_media.pre_execute event.
   */
  public function executeSocialMedia($event) {
    $element = $event
      ->getElement();
    $element['facebook_share']['weight'] = 8;
    $event
      ->setElement($element);
  }

  /**
   * Subscribes to social_media.pre_render event.
   */
  public function renderSocialMedia($event) {
    $element = $event
      ->getElement();
    $element['facebook_msg']['text'] = 'New facebook msg text';
    $event
      ->setElement($element);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
SocialMediaSubscriber::addMoreSocialMedia public function Subscribes to social_media.add_more_social_media event.
SocialMediaSubscriber::executeSocialMedia public function Subscribes to social_media.pre_execute event.
SocialMediaSubscriber::getSubscribedEvents public static function Public static method used by Drupals event.
SocialMediaSubscriber::renderSocialMedia public function Subscribes to social_media.pre_render event.