This repository has been archived by the owner on Mar 10, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from M6Web/feature/add-base-bundle
Add base bundle
- Loading branch information
Showing
40 changed files
with
2,479 additions
and
1 deletion.
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,3 @@ | ||
<?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,3 @@ | ||
<?php | ||
|
||
require __DIR__ . '/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,10 @@ | ||
# Standard used by PHP CodeSniffer (required) | ||
standard=vendor/m6web/symfony2-coding-standard/Symfony2 | ||
|
||
# White list of files and directories (optional) | ||
. | ||
|
||
# Black list of files and directories (optional) | ||
!Tests/ | ||
!vendor/ | ||
!bin/ |
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 @@ | ||
bin/ | ||
vendor/ | ||
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 | ||
|
||
branches: | ||
only: | ||
- master | ||
|
||
install: | ||
- composer install -n --dev | ||
|
||
script: | ||
- bin/atoum |
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,46 @@ | ||
# Contributing | ||
|
||
First of all, **thank you** for contributing, **you are awesome**! | ||
|
||
Here are few rules to follow for a easier code review before the maintainers accept and merge your request. | ||
|
||
##### Rules development | ||
|
||
- Run the test suite. | ||
- Write (or update) unit tests. | ||
- Write (or update) documentation. | ||
- Write [commit messages that make sense](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html) | ||
|
||
##### Rules Pull Request | ||
- [Rebase your branch](http://git-scm.com/book/en/Git-Branching-Rebasing) before submitting your Pull Request. | ||
- [Squash your commits] to "clean" your pull request before merging (http://gitready.com/advanced/2009/02/10/squashing-commits-with-rebase.html). | ||
- Write and good description which gives the context and/or explains why you are creating it. | ||
|
||
**Thank you!** | ||
|
||
|
||
### Install project to development | ||
|
||
Get sources dependancies : | ||
|
||
``` | ||
composer install | ||
``` | ||
|
||
### Unit tests | ||
|
||
Launch unit tests with Atoum | ||
|
||
``` | ||
./bin/atoum | ||
``` | ||
|
||
### Check style | ||
|
||
Check style use [Coke](https://github.com/M6Web/Coke) | ||
|
||
Start code analysis : | ||
|
||
``` | ||
./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,56 @@ | ||
<?php | ||
|
||
namespace M6Web\Bundle\ApiExceptionBundle\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 | ||
*/ | ||
class Configuration implements ConfigurationInterface | ||
{ | ||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function getConfigTreeBuilder() | ||
{ | ||
$treeBuilder = new TreeBuilder(); | ||
$rootNode = $treeBuilder->root('m6web_api_exception'); | ||
|
||
$rootNode | ||
->children() | ||
->booleanNode('stack_trace')->defaultValue(false)->end() | ||
->booleanNode('match_all')->defaultValue(true)->end() | ||
->arrayNode('default') | ||
->addDefaultsIfNotSet() | ||
->children() | ||
->integerNode('code')->defaultValue(0)->end() | ||
->integerNode('status')->defaultValue(500)->end() | ||
->scalarNode('message')->defaultValue('Internal server error')->end() | ||
->arrayNode('headers') | ||
->useAttributeAsKey('name') | ||
->prototype('scalar')->end() | ||
->defaultValue([]) | ||
->end() | ||
->end() | ||
->end() | ||
->arrayNode('exceptions') | ||
->useAttributeAsKey('name') | ||
->prototype('array') | ||
->children() | ||
->integerNode('code')->end() | ||
->integerNode('status')->end() | ||
->scalarNode('message')->end() | ||
->arrayNode('headers') | ||
->useAttributeAsKey('name') | ||
->prototype('scalar')->end() | ||
->end() | ||
->end() | ||
->end() | ||
->end() | ||
->end(); | ||
|
||
return $treeBuilder; | ||
} | ||
} |
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,83 @@ | ||
<?php | ||
|
||
namespace M6Web\Bundle\ApiExceptionBundle\DependencyInjection; | ||
|
||
use Symfony\Component\DependencyInjection\ContainerBuilder; | ||
use Symfony\Component\HttpKernel\DependencyInjection\Extension; | ||
use Symfony\Component\DependencyInjection\Definition; | ||
use Symfony\Component\DependencyInjection\Reference; | ||
|
||
/** | ||
* This is the class that loads and manages your bundle configuration | ||
*/ | ||
class M6WebApiExceptionExtension extends Extension | ||
{ | ||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function load(array $configs, ContainerBuilder $container) | ||
{ | ||
$configuration = new Configuration(); | ||
$config = $this->processConfiguration($configuration, $configs); | ||
|
||
$this->loadExceptionManager($container, $config); | ||
$this->loadExceptionListener($container, $config); | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getAlias() | ||
{ | ||
return 'm6web_api_exception'; | ||
} | ||
|
||
/** | ||
* load service exception manager | ||
* | ||
* @param ContainerBuilder $container | ||
* @param array $config | ||
*/ | ||
protected function loadExceptionManager(ContainerBuilder $container, array $config) | ||
{ | ||
$definition = new Definition( | ||
'M6Web\Bundle\ApiExceptionBundle\Manager\ExceptionManager', | ||
[ | ||
$config['default'], | ||
$config['exceptions'], | ||
] | ||
); | ||
|
||
$container->setDefinition($this->getAlias().'.manager.exception', $definition); | ||
} | ||
|
||
/** | ||
* load service exception listener | ||
* | ||
* @param ContainerBuilder $container | ||
* @param array $config | ||
*/ | ||
protected function loadExceptionListener(ContainerBuilder $container, array $config) | ||
{ | ||
$definition = new Definition( | ||
'M6Web\Bundle\ApiExceptionBundle\EventListener\ExceptionListener', | ||
[ | ||
new Reference('kernel'), | ||
new Reference($this->getAlias().'.manager.exception'), | ||
$config['match_all'], | ||
$config['default'], | ||
$config['stack_trace'], | ||
] | ||
); | ||
|
||
$definition->addTag( | ||
'kernel.event_listener', | ||
[ | ||
'event' => 'kernel.exception', | ||
'method' => 'onKernelException', | ||
] | ||
); | ||
|
||
$container->setDefinition($this->getAlias().'.listener.exception', $definition); | ||
} | ||
} |
Oops, something went wrong.