From 4f187ad08a7dd6a30ce5a27a8a6bd7fabdba646f Mon Sep 17 00:00:00 2001 From: Tim Schumacher Date: Thu, 31 Jul 2014 09:51:34 +0200 Subject: [PATCH] Added the url to the ics file. --- composer.json | 2 +- .../Controller/LocationController.php | 14 +++++++++++++- .../CalciferBundle/Controller/TagController.php | 16 +++++++++++++--- .../Bundle/CalciferBundle/Entity/Location.php | 4 ++++ 4 files changed, 31 insertions(+), 5 deletions(-) diff --git a/composer.json b/composer.json index 3ee53f9..4823ea7 100755 --- a/composer.json +++ b/composer.json @@ -33,7 +33,7 @@ "incenteev/composer-parameter-handler": "~2.0", "jquery/jquery": "1.10.*", "knplabs/knp-markdown-bundle": "~1.3", - "jsvrcek/ics": "dev-master", + "enko/ics": "~0.1", "doctrine/migrations": "dev-master", "doctrine/doctrine-migrations-bundle": "dev-master", "jbroadway/urlify" : "~1.0" diff --git a/src/Hackspace/Bundle/CalciferBundle/Controller/LocationController.php b/src/Hackspace/Bundle/CalciferBundle/Controller/LocationController.php index 3815bfd..631892a 100755 --- a/src/Hackspace/Bundle/CalciferBundle/Controller/LocationController.php +++ b/src/Hackspace/Bundle/CalciferBundle/Controller/LocationController.php @@ -24,7 +24,7 @@ use Jsvrcek\ICS\Model\Relationship\Organizer; use Jsvrcek\ICS\Utility\Formatter; use Jsvrcek\ICS\CalendarStream; use Jsvrcek\ICS\CalendarExport; -use Symfony\Component\Validator\Constraints\DateTime; +use Jsvrcek\ICS\Model\Description\Geo; /** * Location controller. @@ -82,6 +82,18 @@ class LocationController extends Controller if ($entity->enddate instanceof \DateTime) $event->setEnd($entity->enddate); $event->setSummary($entity->summary); + $event->setUrl($entity->url); + if ($entity->location instanceof Location) { + $location = new \Jsvrcek\ICS\Model\Description\Location(); + $location->setName($entity->location->name); + $event->setLocations([$location]); + if (\is_float($entity->location->lon) && \is_float($entity->location->lat)) { + $geo = new Geo(); + $geo->setLatitude($entity->location->lat); + $geo->setLongitude($entity->location->lon); + $event->setGeo($geo); + } + } $event->setDescription($entity->description); $location = new \Jsvrcek\ICS\Model\Description\Location(); $location->setName($entity->getLocation()->name); diff --git a/src/Hackspace/Bundle/CalciferBundle/Controller/TagController.php b/src/Hackspace/Bundle/CalciferBundle/Controller/TagController.php index bcb0a40..dfb63f5 100755 --- a/src/Hackspace/Bundle/CalciferBundle/Controller/TagController.php +++ b/src/Hackspace/Bundle/CalciferBundle/Controller/TagController.php @@ -7,6 +7,7 @@ use Doctrine\ORM\EntityRepository; use Doctrine\ORM\QueryBuilder; use Hackspace\Bundle\CalciferBundle\Entity\Location; use Hackspace\Bundle\CalciferBundle\Entity\Tag; +use Jsvrcek\ICS\Model\Description\Geo; use Symfony\Component\HttpFoundation\Request; use Symfony\Bundle\FrameworkBundle\Controller\Controller; use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method; @@ -79,9 +80,18 @@ class TagController extends Controller $event->setEnd($entity->enddate); $event->setSummary($entity->summary); $event->setDescription($entity->description); - $location = new \Jsvrcek\ICS\Model\Description\Location(); - $location->setName($entity->location->name); - $event->setLocations([$location]); + $event->setUrl($entity->url); + if ($entity->location instanceof Location) { + $location = new \Jsvrcek\ICS\Model\Description\Location(); + $location->setName($entity->location->name); + $event->setLocations([$location]); + if (\is_float($entity->location->lon) && \is_float($entity->location->lat)) { + $geo = new Geo(); + $geo->setLatitude($entity->location->lat); + $geo->setLongitude($entity->location->lon); + $event->setGeo($geo); + } + } $calendar->addEvent($event); } diff --git a/src/Hackspace/Bundle/CalciferBundle/Entity/Location.php b/src/Hackspace/Bundle/CalciferBundle/Entity/Location.php index af10407..afd6feb 100755 --- a/src/Hackspace/Bundle/CalciferBundle/Entity/Location.php +++ b/src/Hackspace/Bundle/CalciferBundle/Entity/Location.php @@ -7,6 +7,10 @@ use Doctrine\ORM\Mapping as ORM; /** * Location * + * @property string $name + * @property float $lon + * @property float $lat + * * @ORM\Table(name="locations") * @ORM\Entity */