44
55use Symfony \Component \Config \Definition \Builder \TreeBuilder ;
66use Symfony \Component \Config \Definition \ConfigurationInterface ;
7+ use Symfony \Component \HttpKernel \Kernel ;
78
89class Configuration implements ConfigurationInterface
910{
1011 /**
11- * {@inheritDoc }
12+ * {@inheritdoc }
1213 */
1314 public function getConfigTreeBuilder ()
1415 {
@@ -17,38 +18,16 @@ public function getConfigTreeBuilder()
1718
1819 $ rootNode
1920 ->children ()
20- ->arrayNode ('phantomjs ' )
21+ ->arrayNode ('script ' )
2122 ->addDefaultsIfNotSet ()
2223 ->children ()
23- ->scalarNode ('callable ' )->defaultValue ('phantomjs ' )->end ()
24- ->arrayNode ('options ' )
25- ->info ('http://phantomjs.org/api/command-line.html ' )
26- ->defaultValue (
27- [
28- '--output-encoding ' => $ this ->isWin () ? 'ISO-8859-1 ' : 'UTF-8 ' ,
29- ]
30- )
31- ->normalizeKeys (false )
32- ->beforeNormalization ()
33- ->ifTrue (function ($ v ) {
34- return !isset ($ v ['--output-encoding ' ]);
35- })
36- ->then (function ($ v ) {
37- return array_merge (
38- [
39- '--output-encoding ' => $ this ->isWin () ? 'ISO-8859-1 ' : 'UTF-8 ' ,
40- ],
41- $ v
42- );
43- })
44- ->end ()
45- ->prototype ('scalar ' )->end ()
24+ ->scalarNode ('callable ' )->defaultValue ('node ' )->end ()
25+ ->scalarNode ('path ' )
26+ ->defaultValue ($ this ->getAssetsDir () . DIRECTORY_SEPARATOR . 'rasterize.js ' )
27+ ->info ('Relative to project dir ' )
4628 ->end ()
4729 ->end ()
4830 ->end ()
49- ->scalarNode ('script ' )
50- ->defaultValue ('../web/bundles/padam87rasterize/js/rasterize.js ' )->info ('Relative to root dir ' )
51- ->end ()
5231 ->arrayNode ('arguments ' )
5332 ->defaultValue (
5433 [
@@ -71,8 +50,13 @@ public function getConfigTreeBuilder()
7150 return $ treeBuilder ;
7251 }
7352
74- private function isWin ()
53+ private function getAssetsDir ()
7554 {
76- return strtoupper (substr (PHP_OS , 0 , 3 )) === 'WIN ' ;
55+ switch (Kernel::MAJOR_VERSION ) {
56+ case 4 :
57+ return 'assets ' ;
58+ default :
59+ return 'web ' ;
60+ }
7761 }
7862}
0 commit comments