Skip to content

Commit

Permalink
Merge pull request #40 from Kunstmaan/debug_mode
Browse files Browse the repository at this point in the history
make it possible to enable/disable the debug mode via config.yml
  • Loading branch information
Wim Vandersmissen committed May 7, 2014
2 parents 5d08408 + 6973f4c commit f204687
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 17 deletions.
2 changes: 1 addition & 1 deletion Controller/TranslatorController.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function indexAction()
$adminList->bindRequest($request);

$cacheFresh = $this->get('kunstmaan_translator.service.translator.cache_validator')->isCacheFresh();
$debugMode = $this->container->getParameter('kernel.debug') === true;
$debugMode = $this->container->getParameter('kuma_translator.debug') === true;

if (!$cacheFresh && !$debugMode) {
$noticeText = $this->get('translator')->trans('settings.translator.not_live_warning');
Expand Down
20 changes: 17 additions & 3 deletions DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,23 @@ public function getConfigTreeBuilder()

$rootNode
->children()
->booleanNode('enabled')->defaultTrue()->end()
->scalarNode('default_bundle')->cannotBeEmpty()->defaultValue('kunstmaantranslatorbundle')->end()
->scalarNode('cache_dir')->cannotBeEmpty()->defaultValue("%kernel.cache_dir%/translations")->end()
->booleanNode('enabled')
->defaultTrue()
->end()

->scalarNode('default_bundle')
->cannotBeEmpty()
->defaultValue('kunstmaantranslatorbundle')
->end()

->scalarNode('cache_dir')
->cannotBeEmpty()
->defaultValue("%kernel.cache_dir%/translations")
->end()

->booleanNode('debug')
->defaultValue(null)
->end()

->arrayNode('managed_locales')
->defaultValue(array())
Expand Down
2 changes: 1 addition & 1 deletion DependencyInjection/KunstmaanTranslatorExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ public function load(array $configs, ContainerBuilder $container)
$container->setParameter('kuma_translator.file_formats', $config['file_formats']);
$container->setParameter('kuma_translator.storage_engine.type', $config['storage_engine']['type']);
$container->setParameter('kuma_translator.profiler', $container->getParameter('kernel.debug'));
$container->setParameter('kuma_translator.debug', is_null($config['debug']) ? $container->getParameter('kernel.debug') : $config['debug']);

$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
$loader->load('services.yml');
$loader->load('repositories.yml');
//$loader->load('validators.yml');

$this->setTranslationConfiguration($config, $container);
}
Expand Down
6 changes: 3 additions & 3 deletions Resources/config/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,14 @@ services:
kunstmaan_translator.service.translator.resource_cacher:
class: Kunstmaan\TranslatorBundle\Service\Translator\ResourceCacher
calls:
- [setDebug, [%kernel.debug%]]
- [setDebug, [%kuma_translator.debug%]]
- [setCacheDir, [%kuma_translator.cache_dir%]]
- [setLogger, [@logger]]

kunstmaan_translator.service.translator.cache_validator:
class: Kunstmaan\TranslatorBundle\Service\Translator\CacheValidator
calls:
- [setDebug, [%kernel.debug%]]
- [setDebug, [%kuma_translator.debug%]]
- [setCacheDir, [%kuma_translator.cache_dir%]]
- [setTranslationRepository, [@kunstmaan_translator.repository.translation]]

Expand All @@ -92,7 +92,7 @@ services:
- @service_container
- @translator.selector
- {}
- { cache_dir : %kuma_translator.cache_dir%, debug: %kernel.debug% }
- { cache_dir : %kuma_translator.cache_dir%, debug: %kuma_translator.debug% }
- [@session]
calls:
- [setTranslationRepository, [@kunstmaan_translator.repository.translation]]
Expand Down
7 changes: 0 additions & 7 deletions Resources/config/validators.yml

This file was deleted.

1 change: 0 additions & 1 deletion Service/Translator/CacheValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
class CacheValidator
{
/**
* AppKernel running in debug or not
* @var boolean
*/
private $debug;
Expand Down
2 changes: 1 addition & 1 deletion Service/Translator/ResourceCacher.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@

use Symfony\Component\Config\ConfigCache;
use Symfony\Component\Process\Exception\RuntimeException;

/**
* ResourceCacher is used to cache all the resource into a file
*/
class ResourceCacher
{
/**
* AppKernel running in debug or not
* @var boolean
*/
private $debug;
Expand Down

0 comments on commit f204687

Please sign in to comment.