diff --git a/.gitignore b/.gitignore index 62718f4..7c60054 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ .idea/ /vendor/ composer.lock -gi \ No newline at end of file +.DS_Store \ No newline at end of file diff --git a/Event/CalendarEvent.php b/Event/CalendarEvent.php index 30ddb7c..70d3bde 100644 --- a/Event/CalendarEvent.php +++ b/Event/CalendarEvent.php @@ -3,6 +3,7 @@ namespace AncaRebeca\FullCalendarBundle\Event; use AncaRebeca\FullCalendarBundle\Model\EventInterface; +use AncaRebeca\FullCalendarBundle\Model\FullCalendarEvent; use Symfony\Component\EventDispatcher\Event as EventDispatcher; class CalendarEvent extends EventDispatcher @@ -66,11 +67,11 @@ public function getFilters() } /** - * @param EventInterface $event + * @param FullCalendarEvent $event * * @return $this */ - public function addEvent(EventInterface $event) + public function addEvent(FullCalendarEvent $event) { if (!in_array($event, $this->events, true)) { $this->events[] = $event; @@ -80,7 +81,7 @@ public function addEvent(EventInterface $event) } /** - * @return EventInterface[] + * @return FullCalendarEvent[] */ public function getEvents() { diff --git a/Model/EventInterface.php b/Model/EventInterface.php index 6c13e32..2601c62 100644 --- a/Model/EventInterface.php +++ b/Model/EventInterface.php @@ -2,11 +2,17 @@ namespace AncaRebeca\FullCalendarBundle\Model; +/** + * Interface EventInterface + * @deprecated since version V4.1.0, to be removed in v5.0.0. Use FullCalendarEvent instead + * + */ interface EventInterface { /** * @param string $title * @param \DateTime $start + * */ public function __construct($title, \DateTime $start); diff --git a/Model/FullCalendarEvent.php b/Model/FullCalendarEvent.php new file mode 100644 index 0000000..63f6790 --- /dev/null +++ b/Model/FullCalendarEvent.php @@ -0,0 +1,31 @@ +title = $title; + $this->startDate = $start; + } + + /** + * @return array + */ + abstract public function toArray(); +} \ No newline at end of file diff --git a/README.md b/README.md index adbdda1..12a5ed4 100644 --- a/README.md +++ b/README.md @@ -49,9 +49,9 @@ public function registerBundles() namespace AppBundle\Entity; -use AncaRebeca\FullCalendarBundle\Model\Event as BaseEvent; +use AncaRebeca\FullCalendarBundle\Model\FullCalendarEvent; -class CalendarEvent extends BaseEvent +class CalendarEvent extends FullCalendarEvent { // Your fields } @@ -79,7 +79,7 @@ This listener is called when the event 'fullcalendar.set_data' is launched, for namespace AppBundle\Listener; -use AncaRebeca\FullCalendarBundle\Event\CalendarEvent; +use AncaRebeca\FullCalendarBundle\Model\FullCalendarEvent; use AppBundle\Entity\CalendarEvent as MyCustomEvent; class LoadDataListener @@ -87,7 +87,7 @@ class LoadDataListener /** * @param CalendarEvent $calendarEvent * - * @return EventInterface[] + * @return FullCalendarEvent[] */ public function loadData(CalendarEvent $calendarEvent) { diff --git a/Service/Serializer.php b/Service/Serializer.php index 3379e7e..fe9b1d5 100644 --- a/Service/Serializer.php +++ b/Service/Serializer.php @@ -2,12 +2,12 @@ namespace AncaRebeca\FullCalendarBundle\Service; -use AncaRebeca\FullCalendarBundle\Model\EventInterface; +use AncaRebeca\FullCalendarBundle\Model\FullCalendarEvent; class Serializer implements SerializerInterface { /** - * @param EventInterface[] $events + * @param FullCalendarEvent[] $events * * @return string json */ @@ -15,7 +15,6 @@ public function serialize(array $events) { $result = []; - /** @var EventInterface $event */ foreach ($events as $event) { $result[] = $event->toArray(); } diff --git a/Service/SerializerInterface.php b/Service/SerializerInterface.php index 0e1d377..b726438 100644 --- a/Service/SerializerInterface.php +++ b/Service/SerializerInterface.php @@ -2,12 +2,12 @@ namespace AncaRebeca\FullCalendarBundle\Service; -use AncaRebeca\FullCalendarBundle\Model\EventInterface; +use AncaRebeca\FullCalendarBundle\Model\FullCalendarEvent; interface SerializerInterface { /** - * @param EventInterface[] $events + * @param FullCalendarEvent[] $events * * @return string json */ diff --git a/spec/Model/EventSpec.php b/spec/Model/EventSpec.php index 8284af2..2efe90e 100644 --- a/spec/Model/EventSpec.php +++ b/spec/Model/EventSpec.php @@ -24,10 +24,6 @@ function it_is_initializable() $this->shouldHaveType('AncaRebeca\FullCalendarBundle\Model\Event'); } - function it_should_implement_an_event_interface() - { - $this->shouldImplement('AncaRebeca\FullCalendarBundle\Model\EventInterface'); - } function it_has_require_values() { diff --git a/spec/Service/CalendarSpec.php b/spec/Service/CalendarSpec.php index 35d8886..ae7b2df 100644 --- a/spec/Service/CalendarSpec.php +++ b/spec/Service/CalendarSpec.php @@ -3,7 +3,7 @@ namespace spec\AncaRebeca\FullCalendarBundle\Service; use AncaRebeca\FullCalendarBundle\Event\CalendarEvent; -use AncaRebeca\FullCalendarBundle\Model\EventInterface; +use AncaRebeca\FullCalendarBundle\Model\FullCalendarEvent; use AncaRebeca\FullCalendarBundle\Service\SerializerInterface; use PhpSpec\ObjectBehavior; use Prophecy\Argument; @@ -25,7 +25,7 @@ function it_gets_a_json_string( SerializerInterface $serializer, EventDispatcherInterface $dispatcher, CalendarEvent $calendarEvent, - EventInterface $event + FullCalendarEvent $event ) { $startDate = new \DateTime(); $endDate = new \DateTime(); diff --git a/spec/Service/SerializerSpec.php b/spec/Service/SerializerSpec.php index 089e053..9397188 100644 --- a/spec/Service/SerializerSpec.php +++ b/spec/Service/SerializerSpec.php @@ -2,7 +2,7 @@ namespace spec\AncaRebeca\FullCalendarBundle\Service; -use AncaRebeca\FullCalendarBundle\Model\EventInterface; +use AncaRebeca\FullCalendarBundle\Model\FullCalendarEvent; use PhpSpec\ObjectBehavior; use Prophecy\Argument; @@ -13,7 +13,7 @@ function it_is_initializable() $this->shouldHaveType('AncaRebeca\FullCalendarBundle\Service\Serializer'); } - function it_serialzes_data_successfully(EventInterface $event1, EventInterface $event2) + function it_serialzes_data_successfully(FullCalendarEvent $event1, FullCalendarEvent $event2) { $event1->toArray()->shouldBeCalled()->willReturn(['title' => 'Event 1', 'start' => '20/01/2015']); $event2->toArray()->shouldBeCalled()->willReturn(['title' => 'Event 2', 'start' => '21/01/2015']);