Permalink
Browse files

First commit

  • Loading branch information...
gigo6000 committed Oct 27, 2012
0 parents commit 1e6ad7f73b78cf922b72c0f514d7aa770c0a6d5d
@@ -0,0 +1,97 @@
+<?php
+
+namespace Devtime\Bundle\RafflerBundle\Controller;
+
+use Symfony\Bundle\FrameworkBundle\Controller\Controller;
+use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
+use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
+use Symfony\Component\HttpFoundation\Response;
+
+class DefaultController extends Controller
+{
+ /**
+ * @Route("/raffler")
+ * @Template()
+ */
+ public function indexAction()
+ {
+ return array();
+ }
+ /**
+ *
+ * @Route("/api/entries/{id}")
+ */
+ public function apiEntryUpdateAction()
+ {
+ $request = $this->get('request');
+
+ $params = array();
+ $content = $request->getContent();
+ if (!empty($content))
+ {
+ $params = json_decode($content, true); // 2nd param to get as array
+ }
+
+ if ($request->getMethod() == 'PUT')
+ {
+ if (empty($params['id']))
+ {
+ $errors = array ('errors' => array('id' => array('id can\'t be blank')));
+ $response = new Response(json_encode($errors));
+ $response->setStatusCode(422);
+ return $response;
+
+ }
+
+ //TODO: update entries array
+ return new Response();
+
+ }
+
+
+ }
+
+ /**
+ *
+ * @Route("/api/entries")
+ */
+ public function apiEntriesAction()
+ {
+
+ $entries = array(
+ array('id'=>1,'name' => '@gigo6000', 'winner' => false),
+ array('id'=>2,'name' => '@symfonycol', 'winner' => false)
+ );
+
+ $request = $this->get('request');
+
+ $params = array();
+ $content = $request->getContent();
+ if (!empty($content))
+ {
+ $params = json_decode($content, true); // 2nd param to get as array
+ }
+
+ if ($request->getMethod() == 'GET')
+ {
+ return new Response(json_encode($entries));
+ }
+ else
+ if ($request->getMethod() == 'POST')
+ {
+ if (empty($params['name']))
+ {
+ $errors = array ('errors' => array('name' => array('name can\'t be blank')));
+ $response = new Response(json_encode($errors));
+ $response->setStatusCode(422);
+ return $response;
+
+ }
+
+ array_push($entries, array('name' =>$params['name']));
+ return new Response(json_encode($entries));
+
+ }
+ }
+
+}
@@ -0,0 +1,29 @@
+<?php
+
+namespace Devtime\Bundle\RafflerBundle\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('devtime_raffler');
+
+ // Here you should define the parameters that are allowed to
+ // configure your bundle. See the documentation linked above for
+ // more information on that topic.
+
+ return $treeBuilder;
+ }
+}
@@ -0,0 +1,28 @@
+<?php
+
+namespace Devtime\Bundle\RafflerBundle\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 DevtimeRafflerExtension extends Extension
+{
+ /**
+ * {@inheritDoc}
+ */
+ public function load(array $configs, ContainerBuilder $container)
+ {
+ $configuration = new Configuration();
+ $config = $this->processConfiguration($configuration, $configs);
+
+ $loader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
+ $loader->load('services.xml');
+ }
+}
@@ -0,0 +1,9 @@
+<?php
+
+namespace Devtime\Bundle\RafflerBundle;
+
+use Symfony\Component\HttpKernel\Bundle\Bundle;
+
+class DevtimeRafflerBundle extends Bundle
+{
+}
@@ -0,0 +1,20 @@
+<?xml version="1.0" ?>
+
+<container xmlns="http://symfony.com/schema/dic/services"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
+
+ <!--
+ <parameters>
+ <parameter key="devtime_raffler.example.class">Devtime\Bundle\RafflerBundle\Example</parameter>
+ </parameters>
+
+ <services>
+ <service id="devtime_raffler.example" class="%devtime_raffler.example.class%">
+ <argument type="service" id="service_id" />
+ <argument>plain_value</argument>
+ <argument>%parameter_name%</argument>
+ </service>
+ </services>
+ -->
+</container>
No changes.
Oops, something went wrong.

0 comments on commit 1e6ad7f

Please sign in to comment.