forked from ongr-archive/ContentBundle
-
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
ONGR Team
committed
Oct 30, 2014
0 parents
commit f251b94
Showing
37 changed files
with
2,919 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,7 @@ | ||
/.idea/ | ||
.DS_Store | ||
/vendor/ | ||
composer.lock | ||
/Tests/app/cache/ | ||
/Tests/app/logs/ | ||
/Tests/app/build/ |
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,12 @@ | ||
language: php | ||
php: | ||
- 5.4 | ||
- 5.5 | ||
- 5.6 | ||
services: | ||
- elasticsearch | ||
before_script: | ||
- composer update --prefer-dist | ||
script: | ||
- vendor/bin/phpunit | ||
- vendor/bin/phpcs -p --standard=PSR2 --ignore=vendor/,Tests/app/ ./ |
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,53 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the ONGR package. | ||
* | ||
* (c) NFQ Technologies UAB <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace ONGR\ContentBundle\Controller; | ||
|
||
use Symfony\Bundle\FrameworkBundle\Controller\Controller; | ||
use Symfony\Component\HttpFoundation\Response; | ||
|
||
/** | ||
* Controller for content pages. | ||
* | ||
* @SuppressWarnings(UnusedFormalParameter) | ||
*/ | ||
class ContentController extends Controller | ||
{ | ||
/** | ||
* Returns template data for snippetAction. | ||
* | ||
* @param string $slug | ||
* | ||
* @return array | ||
*/ | ||
protected function snippetActionData($slug) | ||
{ | ||
return $this->get('ongr_content.content_service')->getDataForSnippet($slug); | ||
} | ||
|
||
/** | ||
* Render cms body in template. | ||
* | ||
* @param string $slug | ||
* @param string $template | ||
* | ||
* @return Response | ||
*/ | ||
public function snippetAction( | ||
$slug, | ||
$template = 'ONGRContentBundle:Content:plain_cms_snippet.html.twig' | ||
) { | ||
return $this->render( | ||
$template, | ||
$this->snippetActionData($slug) | ||
); | ||
} | ||
} |
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,58 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the ONGR package. | ||
* | ||
* (c) NFQ Technologies UAB <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace ONGR\ContentBundle\DependencyInjection; | ||
|
||
use Symfony\Component\Config\Definition\Builder\TreeBuilder; | ||
use Symfony\Component\Config\Definition\ConfigurationInterface; | ||
|
||
/** | ||
* This is the class that validates and merges configuration from app/config files. | ||
*/ | ||
class Configuration implements ConfigurationInterface | ||
{ | ||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function getConfigTreeBuilder() | ||
{ | ||
$treeBuilder = new TreeBuilder(); | ||
$rootNode = $treeBuilder->root('ongr_content'); | ||
|
||
$rootNode | ||
->children() | ||
->arrayNode('es') | ||
->isRequired() | ||
->children() | ||
->arrayNode('repositories') | ||
->children() | ||
->scalarNode('product')->isRequired()->end() | ||
->scalarNode('content')->isRequired()->end() | ||
->scalarNode('category')->isRequired()->end() | ||
->end() | ||
->end() | ||
->end() | ||
->end() | ||
->arrayNode('snippet') | ||
->cannotBeOverwritten() | ||
->addDefaultsIfNotSet() | ||
->children() | ||
->scalarNode('render_strategy') | ||
->defaultValue('esi') | ||
->info('Default template render strategy') | ||
->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,52 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the ONGR package. | ||
* | ||
* (c) NFQ Technologies UAB <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace ONGR\ContentBundle\DependencyInjection; | ||
|
||
use Symfony\Component\Config\FileLocator; | ||
use Symfony\Component\DependencyInjection\ContainerBuilder; | ||
use Symfony\Component\DependencyInjection\Loader; | ||
use Symfony\Component\DependencyInjection\Reference; | ||
use Symfony\Component\HttpKernel\DependencyInjection\Extension; | ||
|
||
/** | ||
* This is the class that loads and manages bundle configuration. | ||
*/ | ||
class ONGRContentExtension 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'); | ||
|
||
// Inject manager and repository to services. | ||
$repositories = $config['es']['repositories']; | ||
|
||
$container->setParameter('ongr_content.es.repositories', $repositories); | ||
|
||
$contentService = $container->getDefinition('ongr_content.content_service'); | ||
$contentService->addArgument(new Reference($repositories['content'])); | ||
|
||
$twigExtension = $container->getDefinition('ongr_content.twig.content_extension'); | ||
$twigExtension->addArgument(new Reference($repositories['content'])); | ||
|
||
$categoryService = $container->getDefinition('ongr_content.category_service'); | ||
$categoryService->addArgument(new Reference($repositories['category'])); | ||
|
||
$container->setParameter('ongr_content.snippet.render_strategy', $config['snippet']['render_strategy']); | ||
} | ||
} |
Oops, something went wrong.