From 630f39b6e6ed01a4ab3ac3a493f7990280ad5e6c Mon Sep 17 00:00:00 2001 From: Rebeca Mora Anca Date: Fri, 21 Aug 2015 08:16:25 +0100 Subject: [PATCH 1/2] Updating README.md --- README.md | 286 +---------------------------------------------- README.md.old | 299 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 301 insertions(+), 284 deletions(-) create mode 100644 README.md.old diff --git a/README.md b/README.md index b3c82b6..f4a7be0 100644 --- a/README.md +++ b/README.md @@ -8,292 +8,10 @@ This bundle allow you to integrate [FullCalendar.js](http://fullcalendar.io/) li * FullCalendar.js v2.3.2 * Symfony v2.3+ * PHP v5.3+ -* PHPSpec +* PHPSpec Installation ------------ Installation process: -1. [Download FullCalendarBundle using composer](#download-fullcalendarbundle) -2. [Enable bundle](#enable-bundle) -3. [Create your Event class](#create-event) -4. [Create and Configure your own event adapter](#config-adapter) -5. [Add styles and scripts in your template](#styles-scripts) -6. [Add Routing](#routing) - -### 1. Download FullCalendarBundle using composer - -```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 + + Date: Sun, 23 Aug 2015 15:40:42 +0100 Subject: [PATCH 2/2] Updating readme Removing old classes --- .gitignore | 2 + Adapter/CalendarAdapterInterface.php | 17 -- Controller/CalendarController.php | 1 - README.md | 188 ++++++++++++++++- README.md.old | 299 --------------------------- 5 files changed, 188 insertions(+), 319 deletions(-) delete mode 100644 Adapter/CalendarAdapterInterface.php delete mode 100644 README.md.old 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 + + +You need to create your listener/subscriber class in order to load your events data in the calendar. + +```yml +// service.yml +services: + app_bundle.service.listener: + class: AppBundle\Listener\LoadDataListener + tags: + - { name: 'kernel.event_listener', event: 'fullcalendar.set_data', method: loadData } + +``` + +This listener is called when the event 'fullcalendar.set_data' is launched, for this reason you will need add this in your service.yml. + +```php +// src/AppBundle/Listener/LoadDataListener.php + +getStartDatetime(); + $endDate = $calendarEvent->getEndDatetime(); + $filters = $calendarEvent->getFilters(); + + //You may want do a custom query to populate the events + + $calendarEvent->addEvent(new Event('Event Title 1', new \DateTime()); + $calendarEvent->addEvent(new Event('Event Title 2', new \DateTime())); + } +} +``` + +### 5. Add styles and scripts in your template + +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() + } + } +] +``` + +Contribute and feedback +------------------------- + +Any feedback and contribution will be very appreciated. \ No newline at end of file diff --git a/README.md.old b/README.md.old deleted file mode 100644 index b3c82b6..0000000 --- a/README.md.old +++ /dev/null @@ -1,299 +0,0 @@ -## FullCalendarBundle - -[![Build Status](https://travis-ci.org/ancarebeca/FullCalendarBundle.svg)](https://travis-ci.org/ancarebeca/FullCalendarBundle) - -This bundle allow you to integrate [FullCalendar.js](http://fullcalendar.io/) library in your Symfony2. - -## Requirements -* FullCalendar.js v2.3.2 -* Symfony v2.3+ -* PHP v5.3+ -* PHPSpec - -Installation ------------- -Installation process: - -1. [Download FullCalendarBundle using composer](#download-fullcalendarbundle) -2. [Enable bundle](#enable-bundle) -3. [Create your Event class](#create-event) -4. [Create and Configure your own event adapter](#config-adapter) -5. [Add styles and scripts in your template](#styles-scripts) -6. [Add Routing](#routing) - -### 1. Download FullCalendarBundle using composer - -```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 - -