-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Jérémy Jourdin
committed
Nov 13, 2014
0 parents
commit 1061288
Showing
59 changed files
with
2,988 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
<?php | ||
$runner->addTestsFromDirectory(__DIR__.'/Tests/'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
<?php | ||
require 'vendor/autoload.php'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
standard-path=vendor/m6web/symfony2-coding-standard/ | ||
standard=Symfony2 | ||
. | ||
!bin/ | ||
!Tests/ | ||
!vendor/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
/vendor/ | ||
/bin/ | ||
composer.lock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
language: php | ||
php: | ||
- "5.5" | ||
- "5.4" | ||
- "5.3" | ||
|
||
before_script: | ||
- wget http://getcomposer.org/composer.phar | ||
- php composer.phar install --dev | ||
- cp build-tools/travis-ci/.atoum.php .atoum.php | ||
- sed -i s/COVERALLS_TOKEN/$COVERALLS_TOKEN/ .atoum.php | ||
script: | ||
- bin/atoum | ||
- bin/coke |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
|
||
namespace LLS\Bundle\AWSBundle\Annotation; | ||
|
||
/** | ||
* Identity Annotation | ||
* | ||
* @Annotation | ||
* @Target({"PROPERTY", "METHOD"}) | ||
*/ | ||
class Identity | ||
{ | ||
/** | ||
* @var string | ||
*/ | ||
public $name; | ||
|
||
/** | ||
* @Enum({"getter", "setter"}) | ||
*/ | ||
public $type = "getter"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?php | ||
namespace LLS\Bundle\AWSBundle\DependencyInjection\Compiler; | ||
|
||
use Symfony\Component\DependencyInjection\ContainerBuilder; | ||
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; | ||
use Symfony\Component\DependencyInjection\Reference; | ||
|
||
/** | ||
* Push tagged identity factories into the identity manager | ||
* | ||
* @author Jérémy Jourdin <jeremy.jourdin@lelivrescolaire.fr> | ||
*/ | ||
class IdentityCompilerPass implements CompilerPassInterface | ||
{ | ||
/** | ||
* Process data | ||
* | ||
* @param ContainerBuilder $container SF2 Container Builder | ||
*/ | ||
public function process(ContainerBuilder $container) | ||
{ | ||
$taggedServices = $container->findTaggedServiceIds('llsaws.identity.type'); | ||
|
||
foreach ($taggedServices as $id => $tags) { | ||
$definition = $container->getDefinition('llsaws.identity.manager'); | ||
$canonicalId = str_replace('.', '_', $id); | ||
|
||
foreach ($tags as $attributes) { | ||
$definition | ||
->addMethodCall( | ||
'addType', | ||
array( | ||
!empty($attributes['alias']) ? $attributes['alias'] : $canonicalId, | ||
new Reference($id) | ||
) | ||
); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?php | ||
namespace LLS\Bundle\AWSBundle\DependencyInjection\Compiler; | ||
|
||
use Symfony\Component\DependencyInjection\ContainerBuilder; | ||
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; | ||
use Symfony\Component\DependencyInjection\Reference; | ||
|
||
/** | ||
* Push tagged identity factories into the identity manager | ||
* | ||
* @author Jérémy Jourdin <jeremy.jourdin@lelivrescolaire.fr> | ||
*/ | ||
class ServiceCompilerPass implements CompilerPassInterface | ||
{ | ||
/** | ||
* Process data | ||
* | ||
* @param ContainerBuilder $container SF2 Container Builder | ||
*/ | ||
public function process(ContainerBuilder $container) | ||
{ | ||
$taggedServices = $container->findTaggedServiceIds('llsaws.service.type'); | ||
|
||
foreach ($taggedServices as $id => $tags) { | ||
$definition = $container->getDefinition('llsaws.service.manager'); | ||
$canonicalId = str_replace('.', '_', $id); | ||
|
||
foreach ($tags as $attributes) { | ||
$definition | ||
->addMethodCall( | ||
'addType', | ||
array( | ||
!empty($attributes['alias']) ? $attributes['alias'] : $canonicalId, | ||
new Reference($id) | ||
) | ||
); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
<?php | ||
|
||
namespace LLS\Bundle\AWSBundle\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('llsaws'); | ||
$rootNode | ||
->fixXmlConfig('identity') | ||
->append($this->getIdentitiesNode()) | ||
->fixXmlConfig('service') | ||
->append($this->getServicesNode()); | ||
|
||
return $treeBuilder; | ||
} | ||
|
||
protected function getIdentitiesNode() | ||
{ | ||
$treeBuilder = new TreeBuilder(); | ||
|
||
$node = $treeBuilder->root('identities'); | ||
$node | ||
->requiresAtLeastOneElement() | ||
->useAttributeAsKey('name') | ||
->prototype('array') | ||
->children() | ||
->scalarNode('type') | ||
->defaultValue('user') | ||
->end() | ||
->end() | ||
->fixXmlConfig('field') | ||
->children() | ||
->arrayNode('fields') | ||
->useAttributeAsKey('name') | ||
->prototype('scalar')->end() | ||
->end() | ||
->end() | ||
->end(); | ||
|
||
return $node; | ||
} | ||
|
||
protected function getServicesNode() | ||
{ | ||
$treeBuilder = new TreeBuilder(); | ||
|
||
$node = $treeBuilder->root('services'); | ||
$node | ||
->requiresAtLeastOneElement() | ||
->useAttributeAsKey('name') | ||
->prototype('array') | ||
->children() | ||
->scalarNode('type') | ||
->isRequired() | ||
->end() | ||
->scalarNode('identity') | ||
->isRequired() | ||
->end() | ||
->end() | ||
->end(); | ||
|
||
return $node; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
<?php | ||
|
||
namespace LLS\Bundle\AWSBundle\DependencyInjection; | ||
|
||
use Symfony\Component\Config\FileLocator; | ||
use Symfony\Component\DependencyInjection\ContainerBuilder; | ||
use Symfony\Component\DependencyInjection\Loader; | ||
use Symfony\Component\DependencyInjection\Definition; | ||
use Symfony\Component\DependencyInjection\Reference; | ||
use Symfony\Component\HttpKernel\DependencyInjection\Extension; | ||
|
||
/** | ||
* 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 LLSAWSExtension 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'); | ||
|
||
if ($container->hasParameter('test') && $container->getParameter('test') === true) { | ||
$loader->load('services_test.yml'); | ||
} | ||
|
||
if (isset($config['identities'])) { | ||
$this->loadIdentities($container, $config['identities']); | ||
} | ||
|
||
if (isset($config['services'])) { | ||
$this->loadServices($container, $config['services']); | ||
} | ||
} | ||
|
||
protected function loadIdentities(ContainerBuilder $container, array $config) | ||
{ | ||
foreach ($config as $name => $infos) { | ||
$this->createIdentityService($container, $name, $infos['type'], $infos['fields']); | ||
} | ||
|
||
return $this; | ||
} | ||
|
||
protected function createIdentityService(ContainerBuilder $container, $name, $type, $definition) | ||
{ | ||
$container | ||
->setDefinition( | ||
self::getIdentityServiceKey($name), | ||
new Definition( | ||
'LLS\\Bundle\\AWSBundle\\Interfaces\\IdentityInterface', | ||
array( | ||
$type, | ||
$definition | ||
) | ||
) | ||
) | ||
->setFactoryService('llsaws.identity.manager') | ||
->setFactoryMethod('create'); | ||
|
||
return $this; | ||
} | ||
|
||
protected function loadServices(ContainerBuilder $container, array $config) | ||
{ | ||
foreach ($config as $name => $infos) { | ||
$this->createServiceService($container, $name, $infos); | ||
} | ||
|
||
return $this; | ||
} | ||
|
||
protected function createServiceService(ContainerBuilder $container, $name, $attributes) | ||
{ | ||
$container | ||
->setDefinition( | ||
self::getServiceServiceKey($name), | ||
new Definition( | ||
'LLS\\Bundle\\AWSBundle\\Interfaces\\ServiceInterface', | ||
array( | ||
$attributes['type'], | ||
array( | ||
new Reference(self::getIdentityServiceKey($attributes['identity'])), | ||
new Reference('llsaws.client.factory') | ||
) | ||
) | ||
) | ||
) | ||
->setFactoryService('llsaws.service.manager') | ||
->setFactoryMethod('create'); | ||
|
||
return $this; | ||
} | ||
|
||
/** | ||
* Get Identity Service key from it's name | ||
* | ||
* @param string $name Service name | ||
* | ||
* @return string | ||
*/ | ||
public static function getIdentityServiceKey($name) | ||
{ | ||
return sprintf('llsaws.identities.%s', $name); | ||
} | ||
|
||
/** | ||
* Get Service Service key from it's name | ||
* | ||
* @param string $name Service name | ||
* | ||
* @return string | ||
*/ | ||
public static function getServiceServiceKey($name) | ||
{ | ||
return sprintf('llsaws.services.%s', $name); | ||
} | ||
} |
Oops, something went wrong.