-
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
Showing
20 changed files
with
1,158 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,5 @@ | ||
composer.phar | ||
phpunit.xml | ||
vendor/ | ||
data/schema.graphql | ||
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,20 @@ | ||
<?php | ||
|
||
namespace Youshido\CommentsBundle; | ||
|
||
use Symfony\Component\DependencyInjection\ContainerBuilder; | ||
use Symfony\Component\HttpKernel\Bundle\Bundle; | ||
use Youshido\CommentsBundle\DependencyInjection\CommentsExtension; | ||
use Youshido\CommentsBundle\DependencyInjection\CompilerPass\CommentsCompilerPass; | ||
|
||
class CommentsBundle extends Bundle | ||
{ | ||
public function build(ContainerBuilder $container) | ||
{ | ||
parent::build($container); | ||
|
||
$container->addCompilerPass(new CommentsCompilerPass()); | ||
|
||
} | ||
|
||
} |
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,34 @@ | ||
<?php | ||
|
||
namespace Youshido\CommentsBundle\DependencyInjection; | ||
|
||
|
||
use Symfony\Component\Config\FileLocator; | ||
use Symfony\Component\DependencyInjection\Loader; | ||
use Symfony\Component\DependencyInjection\ContainerBuilder; | ||
use Symfony\Component\HttpKernel\DependencyInjection\Extension; | ||
|
||
class CommentsExtension extends Extension | ||
{ | ||
public function load(array $configs, ContainerBuilder $container) | ||
{ | ||
$configuration = new Configuration(); | ||
$config = $this->processConfiguration($configuration, $configs); | ||
|
||
// $container->setParameter('graphql_extensions.files', $config['files']); | ||
$this->setContainerParam($container, 'platform', $config['platform']); | ||
$this->setContainerParam($container, 'host', null); | ||
$this->setContainerParam($container, 'scheme', null); | ||
$this->setContainerParam($container, 'allow_anonymous', $config['allow_anonymous']); | ||
$this->setContainerParam($container, 'max_depth', $config['max_depth']); | ||
|
||
$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config')); | ||
$loader->load('services.yml'); | ||
} | ||
|
||
private function setContainerParam(ContainerBuilder $container, $parameter, $value) | ||
{ | ||
$container->setParameter(sprintf('comments.config.%s', $parameter), $value); | ||
} | ||
|
||
} |
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,32 @@ | ||
<?php | ||
|
||
namespace Youshido\CommentsBundle\DependencyInjection\CompilerPass; | ||
|
||
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; | ||
use Symfony\Component\DependencyInjection\ContainerBuilder; | ||
use Symfony\Component\DependencyInjection\Definition; | ||
use Symfony\Component\DependencyInjection\Reference; | ||
|
||
class CommentsCompilerPass implements CompilerPassInterface | ||
{ | ||
public function process(ContainerBuilder $container) | ||
{ | ||
$storageDefinition = new Definition(); | ||
$models = []; | ||
$platform = $container->getParameter('comments.config.platform'); | ||
switch ($platform) { | ||
case 'orm': | ||
$container->setAlias('comments.om', 'doctrine.orm.entity_manager'); | ||
$models['file'] = 'Youshido\GraphQLExtensionsBundle\Entity\File'; | ||
break; | ||
|
||
case 'odm': | ||
$container->setAlias('comments.om', 'doctrine_mongodb.odm.document_manager'); | ||
$models['file'] = 'Youshido\GraphQLExtensionsBundle\Document\File'; | ||
break; | ||
} | ||
$container->setParameter('comments.models', $models); | ||
} | ||
|
||
|
||
} |
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,44 @@ | ||
<?php | ||
namespace Youshido\CommentsBundle\DependencyInjection; | ||
|
||
use Symfony\Component\Config\Definition\Builder\TreeBuilder; | ||
use Symfony\Component\Config\Definition\ConfigurationInterface; | ||
|
||
/** | ||
* This file is a part of GraphQLExtensionsBundle project. | ||
* | ||
* @author Alexandr Viniychuk <[email protected]> | ||
* created: 2/21/17 11:28 PM | ||
*/ | ||
class Configuration implements ConfigurationInterface | ||
{ | ||
public function getConfigTreeBuilder() | ||
{ | ||
$treeBuilder = new TreeBuilder(); | ||
$rootNode = $treeBuilder->root('graphql_extensions'); | ||
|
||
$rootNode | ||
->children() | ||
->enumNode('storage') | ||
->values(['s3', 'filesystem']) | ||
->cannotBeEmpty() | ||
->defaultValue('filesystem') | ||
->end() | ||
->enumNode('platform') | ||
->values(['odm', 'orm']) | ||
->cannotBeEmpty() | ||
->defaultValue('orm') | ||
->end() | ||
->scalarNode('max_depth') | ||
->defaultValue(1) | ||
->cannotBeEmpty() | ||
->end() | ||
->booleanNode('allow_anonymous') | ||
->defaultValue(false) | ||
->end() | ||
->end(); | ||
return $treeBuilder; | ||
} | ||
|
||
|
||
} |
Oops, something went wrong.