@@ -26,7 +26,6 @@ |
||
26 | 26 | * |
27 | 27 | * @param HandlebarsEnvironment $handlebars A HandlebarsEnvironment instance |
28 | 28 | * @param TemplateNameParserInterface $parser A TemplateNameParserInterface instance |
29 | - * @param FileLocatorInterface $locator A FileLocatorInterface instance |
|
30 | 29 | */ |
31 | 30 | public function __construct(HandlebarsEnvironment $handlebars, TemplateNameParserInterface $parser) |
32 | 31 | { |
@@ -7,13 +7,10 @@ |
||
7 | 7 | namespace JaySDe\HandlebarsBundle; |
8 | 8 | |
9 | 9 | |
10 | -use JaySDe\HandlebarsBundle\Cache\Filesystem; |
|
11 | -use LightnCandy\LightnCandy; |
|
12 | 10 | use Symfony\Bundle\FrameworkBundle\Templating\EngineInterface; |
13 | 11 | use Symfony\Component\Config\FileLocatorInterface; |
14 | 12 | use Symfony\Component\HttpFoundation\Response; |
15 | 13 | use Symfony\Component\Templating\TemplateNameParserInterface; |
16 | -use Symfony\Component\Templating\TemplateReferenceInterface; |
|
17 | 14 | |
18 | 15 | class HandlebarsEngine implements EngineInterface |
19 | 16 | { |
@@ -72,6 +72,9 @@ |
||
72 | 72 | $this->profiler = $profiler; |
73 | 73 | } |
74 | 74 | |
75 | + /** |
|
76 | + * @param string $name |
|
77 | + */ |
|
75 | 78 | public function compile($name) |
76 | 79 | { |
77 | 80 | $source = $this->loader->getSource($name); |
@@ -52,18 +52,18 @@ discard block |
||
52 | 52 | 'debug' => true, |
53 | 53 | 'flags' => $flags, |
54 | 54 | 'helpers' => $helper->getHelperMethods(), |
55 | - 'partialresolver' => function ($cx, $name) use ($loader, &$partials) { |
|
55 | + 'partialresolver' => function($cx, $name) use ($loader, &$partials) { |
|
56 | 56 | $extension = false; |
57 | - if ($loader->exists($name . '.handlebars')) { |
|
57 | + if ($loader->exists($name.'.handlebars')) { |
|
58 | 58 | $extension = '.handlebars'; |
59 | - } else if ($loader->exists($name . '.hbs')) { |
|
59 | + } else if ($loader->exists($name.'.hbs')) { |
|
60 | 60 | $extension = '.hbs'; |
61 | 61 | } |
62 | 62 | if ($extension === false) { |
63 | 63 | return null; |
64 | 64 | } |
65 | - $partials[] = new FileResource($loader->getCacheKey($name . $extension)); |
|
66 | - return $loader->getSource($name . $extension); |
|
65 | + $partials[] = new FileResource($loader->getCacheKey($name.$extension)); |
|
66 | + return $loader->getSource($name.$extension); |
|
67 | 67 | }, |
68 | 68 | ], $options); |
69 | 69 | $this->debug = (bool) $this->options['debug']; |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | } catch (\Exception $e) { |
85 | 85 | throw new LoaderException($e->getMessage()); |
86 | 86 | } |
87 | - $this->cache->write($cacheKey, '<?php // ' . $name . PHP_EOL . $phpStr, $this->partials->getArrayCopy()); |
|
87 | + $this->cache->write($cacheKey, '<?php // '.$name.PHP_EOL.$phpStr, $this->partials->getArrayCopy()); |
|
88 | 88 | |
89 | 89 | return $phpStr; |
90 | 90 | } |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | */ |
135 | 135 | public function loadTemplate($templateName) |
136 | 136 | { |
137 | - $name = (string)$templateName; |
|
137 | + $name = (string) $templateName; |
|
138 | 138 | $cacheKey = $this->getCacheFilename($name); |
139 | 139 | |
140 | 140 | if (!$this->isAutoReload() && file_exists($cacheKey)) { |
@@ -26,7 +26,6 @@ discard block |
||
26 | 26 | /** |
27 | 27 | * Constructor. |
28 | 28 | * |
29 | - * @param string|array $paths A path or an array of paths where to look for templates |
|
30 | 29 | */ |
31 | 30 | public function __construct(FileLocatorInterface $locator, TemplateNameParserInterface $parser) |
32 | 31 | { |
@@ -133,6 +132,7 @@ discard block |
||
133 | 132 | |
134 | 133 | /** |
135 | 134 | * {@inheritdoc} |
135 | + * @return string |
|
136 | 136 | */ |
137 | 137 | public function getCacheKey($name) |
138 | 138 | { |
@@ -141,6 +141,7 @@ discard block |
||
141 | 141 | |
142 | 142 | /** |
143 | 143 | * {@inheritdoc} |
144 | + * @param string $template |
|
144 | 145 | */ |
145 | 146 | public function exists($template) |
146 | 147 | { |
@@ -157,6 +158,9 @@ discard block |
||
157 | 158 | } |
158 | 159 | } |
159 | 160 | |
161 | + /** |
|
162 | + * @param string $name |
|
163 | + */ |
|
160 | 164 | protected function parseName($name, $default = self::MAIN_NAMESPACE) |
161 | 165 | { |
162 | 166 | if (isset($name[0]) && '@' == $name[0]) { |
@@ -178,6 +182,9 @@ discard block |
||
178 | 182 | return preg_replace('#/{2,}#', '/', str_replace('\\', '/', (string) $name)); |
179 | 183 | } |
180 | 184 | |
185 | + /** |
|
186 | + * @return string |
|
187 | + */ |
|
181 | 188 | protected function findTemplate($template, $throw = true) |
182 | 189 | { |
183 | 190 | $name = $this->normalizeName($template); |
@@ -16,7 +16,7 @@ |
||
16 | 16 | { |
17 | 17 | if ($helper instanceof HelperInterface) { |
18 | 18 | $this->helpers[$id] = [$helper, 'handle']; |
19 | - } elseif(is_callable($helper)) { |
|
19 | + } elseif (is_callable($helper)) { |
|
20 | 20 | $this->helpers[$id] = $helper; |
21 | 21 | } |
22 | 22 | } |
@@ -34,7 +34,7 @@ |
||
34 | 34 | ->useAttributeAsKey('paths') |
35 | 35 | ->beforeNormalization() |
36 | 36 | ->always() |
37 | - ->then(function ($paths) { |
|
37 | + ->then(function($paths) { |
|
38 | 38 | $normalized = array(); |
39 | 39 | foreach ($paths as $path => $namespace) { |
40 | 40 | if (is_array($namespace)) { |
@@ -22,11 +22,11 @@ |
||
22 | 22 | $options = isset($options['hash']) ? $options['hash'] : []; |
23 | 23 | $bundle = ''; |
24 | 24 | if (isset($options['bundle'])) { |
25 | - $bundle = $options['bundle'] . ':'; |
|
25 | + $bundle = $options['bundle'].':'; |
|
26 | 26 | unset($options['bundle']); |
27 | 27 | } |
28 | 28 | |
29 | - $cmsKey = $bundle . $context; |
|
29 | + $cmsKey = $bundle.$context; |
|
30 | 30 | |
31 | 31 | $result = $this->translationHelper->handle($cmsKey, $options); |
32 | 32 |
@@ -54,7 +54,7 @@ |
||
54 | 54 | $count = isset($options['count']) ? $options['count'] : null; |
55 | 55 | $args = []; |
56 | 56 | foreach ($options as $key => $value) { |
57 | - $key = $this->interpolationPrefix . $key . $this->interpolationSuffix; |
|
57 | + $key = $this->interpolationPrefix.$key.$this->interpolationSuffix; |
|
58 | 58 | $args[$key] = $value; |
59 | 59 | } |
60 | 60 |
@@ -29,12 +29,12 @@ discard block |
||
29 | 29 | $flags = 0; |
30 | 30 | if (isset($config['flags'])) { |
31 | 31 | foreach ($config['flags'] as $flag) { |
32 | - $flags = $flags | constant('LightnCandy\LightnCandy::' . $flag); |
|
32 | + $flags = $flags | constant('LightnCandy\LightnCandy::'.$flag); |
|
33 | 33 | } |
34 | 34 | } |
35 | 35 | if (isset($config['excludeFlags'])) { |
36 | 36 | foreach ($config['excludeFlags'] as $flag) { |
37 | - $flags = $flags & ~constant('LightnCandy\LightnCandy::' . $flag); |
|
37 | + $flags = $flags & ~constant('LightnCandy\LightnCandy::'.$flag); |
|
38 | 38 | } |
39 | 39 | unset($config['excludeFlags']); |
40 | 40 | } |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | $container->setParameter('handlebars.assetic', $config['assetic']); |
60 | 60 | |
61 | 61 | foreach ($config['translation'] as $key => $value) { |
62 | - $container->setParameter('handlebars.translation.' . $key, $value); |
|
62 | + $container->setParameter('handlebars.translation.'.$key, $value); |
|
63 | 63 | } |
64 | 64 | |
65 | 65 | // register user-configured paths |