Skip to content

Commit

Permalink
First code commit- WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
mmoreram committed Dec 16, 2013
0 parents commit 725ac50
Show file tree
Hide file tree
Showing 17 changed files with 1,075 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
build
phpunit.xml
Resources/doc/_build/*
coverage
composer.lock
vendor
composer.phar
phpcs.log
22 changes: 22 additions & 0 deletions Annotation/Abstracts/Annotation.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

/**
* Controller Extra Bundle
*
* @author Marc Morera <[email protected]>
* @since 2013
*/

namespace Mmoreram\ControllerExtraBundle\Annotation\Abstracts;

use Doctrine\Common\Annotations\Annotation as DoctrineAnnotation;

/**
* Flush annotation driver
*
* @Annotation
*/
abstract class Annotation extends DoctrineAnnotation
{

}
22 changes: 22 additions & 0 deletions Annotation/Flush.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

/**
* Controller Extra Bundle
*
* @author Marc Morera <[email protected]>
* @since 2013
*/

namespace Mmoreram\ControllerExtraBundle\Annotation;

use Mmoreram\ControllerExtraBundle\Annotation\Abstracts\Annotation;

/**
* Flush annotation driver
*
* @Annotation
*/
class Flush extends Annotation
{

}
44 changes: 44 additions & 0 deletions Annotation/Form.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php

/**
* Controller Extra Bundle
*
* @author Marc Morera <[email protected]>
* @since 2013
*/

namespace Mmoreram\ControllerExtraBundle\Annotation;

use Mmoreram\ControllerExtraBundle\Annotation\Abstracts\Annotation;

/**
* Form annotation driver
*
* @Annotation
*/
class Form extends Annotation
{

/**
* @var string
*
* Variable where to put generated object
*/
public $variable;


/**
* @var entity
*
* Entity from paramconverter process to use where building form
*/
public $entity;


/**
* @var boolean
*
* Handle request
*/
public $handleRequest = false;
}
76 changes: 76 additions & 0 deletions Annotation/Paginator.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
<?php

/**
* Controller Extra Bundle
*
* @author Marc Morera <[email protected]>
* @since 2013
*/

namespace Mmoreram\ControllerExtraBundle\Annotation;

use Mmoreram\ControllerExtraBundle\Annotation\Abstracts\Annotation;

/**
* Flush annotation driver
*
* @Annotation
*/
class Paginator extends Annotation
{

/**
* @var string
*
* Entity
*/
public $entity;


/**
* @var string
*
* Number of Results per page
*/
public $number;


/**
* @var string
*
* Page
*/
public $page;


/**
* @var string
*
* OrderBy field in Route
*/
public $orderByField;


/**
* @var array
*
* Mapper for OrderBy field
*/
public $orderByFieldMapper = array();


/**
* @var string
*
* OrderBy mode ( asc or desc )
*/
public $orderByMode;


/**
* @var array
*
* Mapper for OrderBy mode
*/
public $orderByModeMapper = array();
}
40 changes: 40 additions & 0 deletions ControllerExtraBundle.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php

/**
* Controller Extra Bundle
*
* @author Marc Morera <[email protected]>
* @since 2013
*/

namespace Mmoreram\ControllerExtra;

use Symfony\Component\HttpKernel\Bundle\Bundle;
use Doctrine\Common\Annotations\AnnotationRegistry;

/**
* ControllerExtraBundle, an extension of Bundle
*/
class ControllerExtraBundle extends Bundle
{

/**
* Boots the Bundle.
*/
public function boot()
{
$kernel = $this->container->get('kernel');

AnnotationRegistry::registerFile($kernel
->locateResource("@ControllerExtraBundle/Annotation/Form.php")
);

AnnotationRegistry::registerFile($kernel
->locateResource("@ControllerExtraBundle/Annotation/Flush.php")
);

AnnotationRegistry::registerFile($kernel
->locateResource("@ControllerExtraBundle/Annotation/Paginator.php")
);
}
}
70 changes: 70 additions & 0 deletions DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<?php

/**
* Controller Extra Bundle
*
* @author Marc Morera <[email protected]>
* @since 2013
*/

namespace Mmoreram\ControllerExtraBundle\DependencyInjection;

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

/**
* Dependency Injection configuration
*/
class Configuration implements ConfigurationInterface
{
/**
* {@inheritDoc}
*/
public function getConfigTreeBuilder()
{
$treeBuilder = new TreeBuilder();
$rootNode = $treeBuilder->root('controller_extra');

$rootNode
->children()
->arrayNode('form')
->addDefaultsIfNotSet()
->children()
->scalarNode('active')
->defaultTrue()
->end()
->end()
->end()
->arrayNode('flush')
->addDefaultsIfNotSet()
->children()
->scalarNode('active')
->defaultTrue()
->end()
->end()
->end()
->arrayNode('paginator')
->addDefaultsIfNotSet()
->children()
->scalarNode('active')
->defaultTrue()
->end()
->scalarNode('number_default')
->defaultValue(10)
->end()
->scalarNode('page_default')
->defaultValue(1)
->end()
->scalarNode('orderby_field_default')
->defaultValue('id')
->end()
->scalarNode('orderby_mode_default')
->defaultValue('desc')
->end()
->end()
->end()
->end();

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

/**
* Controller Extra Bundle
*
* @author Marc Morera <[email protected]>
* @since 2013
*/

namespace Mmoreram\ControllerExtraBundle\DependencyInjection;

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

/**
* This is the class that loads and manages your bundle configuration
*/
class ControllerExtraExtension extends Extension
{
/**
* {@inheritDoc}
*/
public function load(array $configs, ContainerBuilder $container)
{
$configuration = new Configuration();
$config = $this->processConfiguration($configuration, $configs);

$container->setParameter('mmoreram.controllerextra.form_active', $config['form']['active']);
$container->setParameter('mmoreram.controllerextra.flush_active', $config['flush']['active']);
$container->setParameter('mmoreram.controllerextra.paginator_active', $config['paginator']['active']);
$container->setParameter('mmoreram.controllerextra.paginator_number_default', $config['paginator']['number_default']);
$container->setParameter('mmoreram.controllerextra.paginator_page_default', $config['paginator']['page_default']);
$container->setParameter('mmoreram.controllerextra.paginator_orderby_field_default', $config['paginator']['orderby_field_default']);
$container->setParameter('mmoreram.controllerextra.paginator_orderby_mode_default', $config['paginator']['orderby_mode_default']);

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

0 comments on commit 725ac50

Please sign in to comment.