carlescliment / calendar-bundle

A bundle for managing calendars in Symfony 2
40 stars 16 forks source link

Use API to get events #16

Closed drumslk closed 9 years ago

drumslk commented 9 years ago

Hi !

I'm using your bundle, thank you, it's pretty easy and powerful :) I need know to get the last events to create a list in a sidebar, I looked into the controllers, found useful action, but I don't know how to use it ... For Example, this action will be perfect :

calendar_event_list_by_month: pattern: /calendar/by_month/{year}/{month} defaults: { _controller: BladeTesterCalendarBundle:Event:listByMonth }

There is no template, so I don't really understand ... I'm beginner ;)

Thanks for your help !

carlescliment commented 9 years ago

Hi @drumslk.

You can write any controller action on your own and use the manager to retrieve the events you need.

public function lastEventsAction()
{
    $max_events = 10;
    $events = $this->get('blade_tester_calendar.calendar')->findLastLimitTo($max_events);

    return $this->render('AcmeCalendarBundle:Sidebar:list.html.twig', ['events' => $events]);
}

Then you just need to extend the repository and implement the findLastLimitTo($max_events) method.

Hope this helps.

carlescliment commented 9 years ago

Closed due to inactivity.