Google.php in Add to Cal 8
File
src/Plugin/AddToCal/Type/Google.php
View source
<?php
namespace Drupal\addtocal\Plugin\AddToCal\Type;
use Drupal\addtocal\AddToCalTypeBase;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Routing\TrustedRedirectResponse;
use Drupal\Core\Url;
class Google extends AddToCalTypeBase {
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;
}
public function downloadSubmit(EntityInterface $entity, array $settings, $delta, FormStateInterface $form_state) {
$eventDetails = $this
->extractEventDetails($entity, $settings, $delta);
$url = $this
->generateStructure($eventDetails);
$response = new TrustedRedirectResponse($url
->toString());
$form_state
->setResponse($response);
}
}
Classes
Name |
Description |
Google |
Provides google calendar type. |