Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
ancarebeca committed Aug 16, 2015
0 parents commit 5244fa4
Show file tree
Hide file tree
Showing 44 changed files with 1,535 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.idea/
/vendor/
16 changes: 16 additions & 0 deletions Adapter/CalendarAdapterInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

namespace AncaRebeca\FullCalendarBundle\Adapter;

use AncaRebeca\FullCalendarBundle\Model\EventInterface;

interface CalendarAdapterInterface
{
/**
* @param \Datetime $startDate
* @param \Datetime $endDate
*
* @return EventInterface[]
*/
public function getData(\Datetime $startDate, \Datetime $endDate);
}
36 changes: 36 additions & 0 deletions Controller/CalendarController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php

namespace AncaRebeca\FullCalendarBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;

class CalendarController extends Controller
{
/**
* @param Request $request
*
* @return Response
*/
public function loadAction(Request $request)
{
$startDate = new \DateTime($request->get('start'));
$endDate = new \DateTime($request->get('end'));

$response = new Response();
$response->headers->set('Content-Type', 'application/json');

try {
$content = $this->get('anca_rebeca_full_calendar.service.calendar')->getData($startDate, $endDate);
$response->setContent($content);
$response->setStatusCode(Response::HTTP_OK);
} catch (\Exception $exception) {
$response->setContent([]);
$response->setStatusCode(Response::HTTP_INTERNAL_SERVER_ERROR);
}


return $response;
}
}
31 changes: 31 additions & 0 deletions DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

namespace AncaRebeca\FullCalendarBundle\DependencyInjection;

use Symfony\Component\Config\Definition\Builder\TreeBuilder;
use Symfony\Component\Config\Definition\ConfigurationInterface;

/**
* This is the class that validates and merges configuration from your app/config files
*
* To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/extension.html#cookbook-bundles-extension-config-class}
*/
class Configuration implements ConfigurationInterface
{
/**
* {@inheritdoc}
*/
public function getConfigTreeBuilder()
{
$treeBuilder = new TreeBuilder();
$rootNode = $treeBuilder->root('full_calendar');

$rootNode
->children()
->scalarNode('adapter_class')->isRequired()->cannotBeEmpty()->end()
->scalarNode('serializer_class')->defaultValue('AncaRebeca\FullCalendarBundle\Service\Serializer')->end()
->end();

return $treeBuilder;
}
}
31 changes: 31 additions & 0 deletions DependencyInjection/FullCalendarExtension.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

namespace AncaRebeca\FullCalendarBundle\DependencyInjection;

use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
use Symfony\Component\DependencyInjection\Loader;

/**
* This is the class that loads and manages your bundle configuration
*
* To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/extension.html}
*/
class FullCalendarExtension extends Extension
{
/**
* {@inheritdoc}
*/
public function load(array $configs, ContainerBuilder $container)
{
$configuration = new Configuration();
$config = $this->processConfiguration($configuration, $configs);

$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
$loader->load('services.yml');

$container->setParameter('anca_rebeca_full_calendar.adapter', $config['adapter_class']);
$container->setParameter('anca_rebeca_full_calendar.serializer', $config['serializer_class']);
}
}
9 changes: 9 additions & 0 deletions FullCalendarBundle.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

namespace AncaRebeca\FullCalendarBundle;

use Symfony\Component\HttpKernel\Bundle\Bundle;

class FullCalendarBundle extends Bundle
{
}
8 changes: 8 additions & 0 deletions FullCalendarEvents.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php

namespace AncaRebeca\FullCalendarBundle;

final class FullCalendarEvents
{
const LOAD_CALENDAR = 'full_calendar.load_calendar';
}
Loading

0 comments on commit 5244fa4

Please sign in to comment.