You are here

class Google in Add to Cal 8

Provides google calendar type.

Plugin annotation


@AddToCalType(
  id = "google",
  label = @Translation("Google Calendar"),
  description = @Translation("Google calendar type.")
)

Hierarchy

Expanded class hierarchy of Google

1 string reference to 'Google'
AddToCalForm::buildForm in src/Form/AddToCalForm.php

File

src/Plugin/AddToCal/Type/Google.php, line 20

Namespace

Drupal\addtocal\Plugin\AddToCal\Type
View source
class Google extends AddToCalTypeBase {

  /**
   * Generates a google calendar link
   *
   * @param array $info
   * @return \Drupal\Core\Url
   */
  public function generateStructure(array $info) {
    $url = Url::fromUri('http://www.google.com/calendar/event', [
      'query' => [
        'action' => 'TEMPLATE',
        'text' => $info['title'],
        'dates' => $info['rfc3339']['both'],
        'sprop' => 'website:' . $_SERVER['HTTP_HOST'],
        'location' => $info['location'],
        'details' => $info['description'],
      ],
    ]);
    return $url;
  }

  /**
   * @inheritdoc
   */
  public function downloadSubmit(EntityInterface $entity, array $settings, $delta, FormStateInterface $form_state) {
    $eventDetails = $this
      ->extractEventDetails($entity, $settings, $delta);

    /** @var Url $url */
    $url = $this
      ->generateStructure($eventDetails);

    // External URLS require to be a trusted response
    $response = new TrustedRedirectResponse($url
      ->toString());
    $form_state
      ->setResponse($response);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
AddToCalTypeBase::$dateFormatter protected property The date formatter service.
AddToCalTypeBase::create public static function Creates an instance of the plugin. Overrides ContainerFactoryPluginInterface::create 1
AddToCalTypeBase::DT_FORMAT constant
AddToCalTypeBase::extractEventDetails protected function
AddToCalTypeBase::extractFieldValue protected function
AddToCalTypeBase::getName public function Return the name of the type plugin. Overrides AddToCalTypeInterface::getName
AddToCalTypeBase::RF3339_FORMAT constant
AddToCalTypeBase::rfc3339Date protected function Returns an array containing RFC 3339 formatted start and end dates.
AddToCalTypeBase::__construct public function Constructs a AddToCalPluginBase object. Overrides PluginBase::__construct 1
Google::downloadSubmit public function @inheritdoc Overrides AddToCalTypeInterface::downloadSubmit
Google::generateStructure public function Generates a google calendar link Overrides AddToCalTypeInterface::generateStructure
PluginBase::$configuration protected property Configuration information passed into the plugin. 1
PluginBase::$pluginDefinition protected property The plugin implementation definition. 1
PluginBase::$pluginId protected property The plugin_id.
PluginBase::DERIVATIVE_SEPARATOR constant A string which is used to separate base plugin IDs from the derivative ID.
PluginBase::getBaseId public function Gets the base_plugin_id of the plugin instance. Overrides DerivativeInspectionInterface::getBaseId
PluginBase::getDerivativeId public function Gets the derivative_id of the plugin instance. Overrides DerivativeInspectionInterface::getDerivativeId
PluginBase::getPluginDefinition public function Gets the definition of the plugin implementation. Overrides PluginInspectionInterface::getPluginDefinition 3
PluginBase::getPluginId public function Gets the plugin_id of the plugin instance. Overrides PluginInspectionInterface::getPluginId
PluginBase::isConfigurable public function Determines if the plugin is configurable.