From 6f5ca2d29ace98258bbb5bf886579519e760100f Mon Sep 17 00:00:00 2001 From: Tim Schumacher Date: Sat, 9 May 2015 18:22:21 +0200 Subject: [PATCH] Allow presetting some values when creating an event. Fixes #44 --- .../Controller/EventController.php | 20 ++++++++++++++++++- .../CalciferBundle/Entity/BaseEntity.php | 2 +- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/Hackspace/Bundle/CalciferBundle/Controller/EventController.php b/src/Hackspace/Bundle/CalciferBundle/Controller/EventController.php index 320c931..79ccc0d 100755 --- a/src/Hackspace/Bundle/CalciferBundle/Controller/EventController.php +++ b/src/Hackspace/Bundle/CalciferBundle/Controller/EventController.php @@ -181,10 +181,28 @@ class EventController extends Controller * @Method("GET") * @Template("CalciferBundle:Event:edit.html.twig") */ - public function newAction() + public function newAction(Request $request) { $entity = new Event(); + $entity->description = $request->get('description'); + $entity->summary = $request->get('summary'); + $entity->url = $request->get('url'); + if (strlen($request->get('tags')) > 0) { + $tags = explode(",",$request->get('tags')); + foreach($tags as $tag) { + $_tag = new Tag(); + $_tag->name = $tag; + $entity->tags[] = $_tag; + } + } + + if (strlen($request->get('location')) > 0) { + $location = new Location(); + $location->name = $request->get('location'); + $entity->location = $location; + } + return array( 'entity' => $entity, ); diff --git a/src/Hackspace/Bundle/CalciferBundle/Entity/BaseEntity.php b/src/Hackspace/Bundle/CalciferBundle/Entity/BaseEntity.php index ba972ee..f21c6fa 100755 --- a/src/Hackspace/Bundle/CalciferBundle/Entity/BaseEntity.php +++ b/src/Hackspace/Bundle/CalciferBundle/Entity/BaseEntity.php @@ -46,7 +46,7 @@ abstract class BaseEntity { } } - public function __get($name) { + public function &__get($name) { if (property_exists($this,$name)) { return $this->$name; } else {