Allow presetting some values when creating an event.

Fixes #44
This commit is contained in:
Tim Schumacher 2015-05-09 18:22:21 +02:00
parent 34f58dcded
commit 6f5ca2d29a
2 changed files with 20 additions and 2 deletions

View file

@ -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,
);

View file

@ -46,7 +46,7 @@ abstract class BaseEntity {
}
}
public function __get($name) {
public function &__get($name) {
if (property_exists($this,$name)) {
return $this->$name;
} else {