Permalink
Browse files

Merge pull request #108 from vitaliytv/master

twig params not required
  • Loading branch information...
2 parents 9c62fda + a7ba726 commit cacfdb7b84757cce293c77a9079aa1727f43200d @cedriclombardot committed Apr 10, 2012
Showing with 13 additions and 4 deletions.
  1. +3 −1 DependencyInjection/AdmingeneratorGeneratorExtension.php
  2. +10 −3 EventListener/ControllerListener.php
@@ -41,7 +41,9 @@ public function load(array $configs, ContainerBuilder $container)
$resources[] = 'AdmingeneratorGeneratorBundle:Form:fields.html.twig';
$container->setParameter('twig.form.resources', $resources);
- $container->setParameter('admingenerator.twig', $config['twig']);
+ if (isset($config['twig'])) {
+ $container->setParameter('admingenerator.twig', $config['twig']);
+ }
}
public function getAlias()
@@ -44,10 +44,17 @@ public function onKernelRequest(GetResponseEvent $event)
}
}
- $twig_params = $this->container->getParameter('admingenerator.twig');
+ if($this->container->hasParameter('admingenerator.twig')) {
+ $twig_params = $this->container->getParameter('admingenerator.twig');
+
+ if(isset($twig_params['date_format'])) {
+ $this->container->get('twig')->getExtension('core')->setDateFormat($twig_params['date_format'], '%d days');
+ }
- $this->container->get('twig')->getExtension('core')->setDateFormat($twig_params['date_format'], '%d days');
- $this->container->get('twig')->getExtension('core')->setNumberFormat($twig_params['number_format']['decimal'], $twig_params['number_format']['decimal_point'], $twig_params['number_format']['thousand_separator']);
+ if(isset($twig_params['number_format'])) {
+ $this->container->get('twig')->getExtension('core')->setNumberFormat($twig_params['number_format']['decimal'], $twig_params['number_format']['decimal_point'], $twig_params['number_format']['thousand_separator']);
+ }
+ }
}
protected function getGenerator($generatorYaml)

0 comments on commit cacfdb7

Please sign in to comment.