diff --git a/.gitignore b/.gitignore index 1ddcf91..62718f4 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ .idea/ /vendor/ +composer.lock +gi \ No newline at end of file diff --git a/Adapter/CalendarAdapterInterface.php b/Adapter/CalendarAdapterInterface.php deleted file mode 100644 index fa0f3cb..0000000 --- a/Adapter/CalendarAdapterInterface.php +++ /dev/null @@ -1,17 +0,0 @@ - + +```bash +$> composer require ancarebeca/full-calendar-bundle +``` + +### 2. Enable bundle + +```php +// app/AppKernel.php + +public function registerBundles() +{ + return array( + // ... + new AncaRebeca\FullCalendarBundle\FullCalendarBundle(), + ); +} +``` +### 3. Create your Calendar Event class + +```php +// src/AppBundle/Entity/EventCustom.php + + + +```php +// src/AppBundle/Adapter/CustomAdapter.php + + + +Add html template to display the calendar: + +```twig +{% block body %} + {% include '@FullCalendar/Calendar/calendar.html.twig' %} +{% endblock %} +``` + +Add styles: + +```twig +{% block stylesheets %} + +{% endblock %} +``` + +Add javascript: + +```twig +{% block javascripts %} + + + + +{% endblock %} +``` + +Install assets + +```bash +$> php app/console assets:install web +``` + +### 6. Define routes by default + +```yml +# app/config/config.yml + +ancarebeca_fullcalendar: + resource: "@FullCalendarBundle/Resources/config/routing.yml" +``` + +# Extending Basic functionalities + +## Extending the Calendar Javascript +If you want to customize the FullCalendar javascript you can copy the fullcalendar.default-settings.js in Resources/public/js, and add your own logic: + +```javascript +$(function () { + $('#calendar-holder').fullCalendar({ + header: { + left: 'prev, next', + center: 'title', + right: 'month, agendaWeek, agendaDay' + }, + timezone: ('Europe/London'), + businessHours: { + start: '09:00', + end: '17:30', + dow: [1, 2, 3, 4, 5] + }, + allDaySlot: false, + defaultView: 'agendaWeek', + lazyFetching: true, + firstDay: 1, + selectable: true, + timeFormat: { + agenda: 'h:mmt', + '': 'h:mmt' + }, + columnFormat:{ + month: 'ddd', + week: 'ddd D/M', + day: 'dddd' + }, + editable: true, + eventDurationEditable: true, + eventSources: [ + { + url: /your/custom/route, + type: 'POST', + data: { + + } + error: function() { + //alert() + } + } +] +``` + +## Define your own Controller +You may want to define your own controller. This is specially usefull when you want to use some filters in the calendar: + +```javascript +// custom-settings.js +// ... + eventSources: [ + { + url: /your/custom/route, + type: 'POST', + data: { + userName: 'fulanito' + } + error: function() { + //alert() + } + } +// .... +``` + +```php +get('start')); + $endDate = new \DateTime($request->get('end')); + $filter = [ + 'userName' => $request->get('userName', 'default') + ]; + + $response = new Response(); + $response->headers->set('Content-Type', 'application/json'); + + try { + $content = $this->get('anca_rebeca_full_calendar.service.calendar')->getData($startDate, $endDate, $filters); + $response->setContent($content); + $response->setStatusCode(Response::HTTP_OK); + } catch (\Exception $exception) { + $response->setContent([]); + $response->setStatusCode(Response::HTTP_INTERNAL_SERVER_ERROR); + } + + return $response; + } +} +``` + +## Define your own serializer +You may want to define your own serializer. You only need to: + +Create your serializer implementing the serializer class: + +```php +// src/AppBundle/Serializer/CustomSerializer.php + + - -```bash -$> composer require ancarebeca/full-calendar-bundle -``` - -### 2. Enable bundle - -```php -// app/AppKernel.php - -public function registerBundles() -{ - return array( - // ... - new AncaRebeca\FullCalendarBundle\FullCalendarBundle(), - ); -} -``` -### 3. Create your Calendar Event class - -```php -// src/AppBundle/Entity/EventCustom.php - - - -```php -// src/AppBundle/Adapter/CustomAdapter.php - - - -Add html template to display the calendar: - -```twig -{% block body %} - {% include '@FullCalendar/Calendar/calendar.html.twig' %} -{% endblock %} -``` - -Add styles: - -```twig -{% block stylesheets %} - -{% endblock %} -``` - -Add javascript: - -```twig -{% block javascripts %} - - - - -{% endblock %} -``` - -Install assets - -```bash -$> php app/console assets:install web -``` - -### 6. Define routes by default - -```yml -# app/config/config.yml - -ancarebeca_fullcalendar: - resource: "@FullCalendarBundle/Resources/config/routing.yml" -``` - -# Extending Basic functionalities - -## Extending the Calendar Javascript -If you want to customize the FullCalendar javascript you can copy the fullcalendar.default-settings.js in Resources/public/js, and add your own logic: - -```javascript -$(function () { - $('#calendar-holder').fullCalendar({ - header: { - left: 'prev, next', - center: 'title', - right: 'month, agendaWeek, agendaDay' - }, - timezone: ('Europe/London'), - businessHours: { - start: '09:00', - end: '17:30', - dow: [1, 2, 3, 4, 5] - }, - allDaySlot: false, - defaultView: 'agendaWeek', - lazyFetching: true, - firstDay: 1, - selectable: true, - timeFormat: { - agenda: 'h:mmt', - '': 'h:mmt' - }, - columnFormat:{ - month: 'ddd', - week: 'ddd D/M', - day: 'dddd' - }, - editable: true, - eventDurationEditable: true, - eventSources: [ - { - url: /your/custom/route, - type: 'POST', - data: { - - } - error: function() { - //alert() - } - } -] -``` - -## Define your own Controller -You may want to define your own controller. This is specially usefull when you want to use some filters in the calendar: - -```javascript -// custom-settings.js -// ... - eventSources: [ - { - url: /your/custom/route, - type: 'POST', - data: { - userName: 'fulanito' - } - error: function() { - //alert() - } - } -// .... -``` - -```php -get('start')); - $endDate = new \DateTime($request->get('end')); - $filter = [ - 'userName' => $request->get('userName', 'default') - ]; - - $response = new Response(); - $response->headers->set('Content-Type', 'application/json'); - - try { - $content = $this->get('anca_rebeca_full_calendar.service.calendar')->getData($startDate, $endDate, $filters); - $response->setContent($content); - $response->setStatusCode(Response::HTTP_OK); - } catch (\Exception $exception) { - $response->setContent([]); - $response->setStatusCode(Response::HTTP_INTERNAL_SERVER_ERROR); - } - - return $response; - } -} -``` - -## Define your own serializer -You may want to define your own serializer. You only need to: - -Create your serializer implementing the serializer class: - -```php -// src/AppBundle/Serializer/CustomSerializer.php - -