You are here

AddToOutlook.php in Open Social 10.1.x

File

modules/social_features/social_event/modules/social_event_addtocal/src/Plugin/SocialAddToCalendar/AddToOutlook.php
View source
<?php

namespace Drupal\social_event_addtocal\Plugin\SocialAddToCalendar;

use Drupal\Core\Url;
use Drupal\node\NodeInterface;
use Drupal\social_event_addtocal\Plugin\SocialAddToCalendarBase;

/**
 * Provides add to Google calendar plugin.
 *
 * @SocialAddToCalendar(
 *   id = "outlook",
 *   label = @Translation("Outlook"),
 *   url = "https://outlook.live.com/calendar/0/deeplink/compose",
 *   allDayFormat = "Y-m-d",
 *   dateFormat = "Y-m-d\TH:i:s",
 *   utcDateFormat = "Y-m-d\TH:i:s\Z"
 * )
 */
class AddToOutlook extends SocialAddToCalendarBase {

  /**
   * {@inheritdoc}
   */
  public function generateUrl(NodeInterface $node) {
    $settings = $this
      ->generateSettings($node);
    $options = [
      'query' => [
        'path' => '/calendar/action/compose',
        'rru' => 'addevent',
        'subject' => $settings['title'],
        'startdt' => $settings['dates']['start'],
        'enddt' => $settings['dates']['end'],
        'allday' => $settings['dates']['all_day'] ? 'true' : 'false',
        'location' => $settings['location'],
      ],
      'attributes' => [
        'target' => '_blank',
      ],
    ];
    return Url::fromUri($this->pluginDefinition['url'], $options);
  }

}

Classes

Namesort descending Description
AddToOutlook Provides add to Google calendar plugin.