@@ -48,8 +48,7 @@ |
||
48 | 48 | $parametersBag = $serviceLocator->get('ApplicationParameters'); |
49 | 49 | |
50 | 50 | $config['parameters'] = isset($config['parameters']) ? |
51 | - ArrayUtils::merge($parametersBag->all(), $config['parameters']) : |
|
52 | - $config['parameters'] = $parametersBag->all(); |
|
51 | + ArrayUtils::merge($parametersBag->all(), $config['parameters']) : $config['parameters'] = $parametersBag->all(); |
|
53 | 52 | |
54 | 53 | return $parametersBag->resolveArray($config); |
55 | 54 | } |
@@ -70,7 +70,7 @@ |
||
70 | 70 | /** |
71 | 71 | * Renders a template. |
72 | 72 | * |
73 | - * @param mixed $name A template name |
|
73 | + * @param string $name A template name |
|
74 | 74 | * @param array $parameters An array of parameters to pass to the template |
75 | 75 | * |
76 | 76 | * @throws \InvalidArgumentException if the template does not exist |
@@ -50,7 +50,7 @@ |
||
50 | 50 | * |
51 | 51 | * @param string $cachePath |
52 | 52 | * @param boolean $cacheEnabled |
53 | - * @param string|array $paths A path or an array of paths where to look for resources |
|
53 | + * @param string $paths A path or an array of paths where to look for resources |
|
54 | 54 | */ |
55 | 55 | public function __construct($cachePath, $cacheEnabled, $paths = array()) |
56 | 56 | { |
@@ -94,7 +94,7 @@ |
||
94 | 94 | |
95 | 95 | if ($this->cacheEnabled) { |
96 | 96 | $mode = 0666 & ~umask(); |
97 | - $content = "<?php\nreturn " . var_export($this->mergedConfig, 1) . ';'; |
|
97 | + $content = "<?php\nreturn ".var_export($this->mergedConfig, 1).';'; |
|
98 | 98 | $filesystem = new Filesystem(); |
99 | 99 | $filesystem->dumpFile($this->cachePath, $content, $mode); |
100 | 100 | } |
@@ -12,11 +12,11 @@ |
||
12 | 12 | |
13 | 13 | use NoiseLabs\Bundle\SmartyBundle\Extension\RoutingExtension as BaseRoutingExtension; |
14 | 14 | |
15 | - /** |
|
16 | - * Provides integration of the Routing component with Smarty[Bundle]. |
|
17 | - * |
|
18 | - * @author Vítor Brandão <[email protected]> |
|
19 | - */ |
|
20 | - class RouterExtension extends BaseRoutingExtension |
|
21 | - { |
|
22 | - } |
|
15 | + /** |
|
16 | + * Provides integration of the Routing component with Smarty[Bundle]. |
|
17 | + * |
|
18 | + * @author Vítor Brandão <[email protected]> |
|
19 | + */ |
|
20 | + class RouterExtension extends BaseRoutingExtension |
|
21 | + { |
|
22 | + } |
@@ -10,7 +10,6 @@ |
||
10 | 10 | |
11 | 11 | namespace PPI\Framework\Router\Loader; |
12 | 12 | |
13 | -use Illuminate\Routing\Router; |
|
14 | 13 | use Illuminate\Routing\Router as LaravelRouter; |
15 | 14 | |
16 | 15 | /** |
@@ -40,7 +40,7 @@ |
||
40 | 40 | public function load($path) |
41 | 41 | { |
42 | 42 | if (!is_readable($path)) { |
43 | - throw new \InvalidArgumentException('Invalid laravel routes path found: ' . $path); |
|
43 | + throw new \InvalidArgumentException('Invalid laravel routes path found: '.$path); |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | // localising the object so the $path file can reference $router; |
@@ -58,37 +58,37 @@ |
||
58 | 58 | foreach ($allModuleRoutes as $moduleName => $moduleRoutingResponse) { |
59 | 59 | switch (true) { |
60 | 60 | // @todo - move this to a separate method() |
61 | - case $moduleRoutingResponse instanceof SymfonyRouteCollection: |
|
62 | - $sfRouter = new SymfonyRouter($requestContext, $moduleRoutingResponse, $routerOptions, $logger); |
|
63 | - $sfRouterWrapper = new SymfonyRouterWrapper($sfRouter); |
|
64 | - $chainRouter->add($sfRouterWrapper); |
|
65 | - break; |
|
61 | + case $moduleRoutingResponse instanceof SymfonyRouteCollection: |
|
62 | + $sfRouter = new SymfonyRouter($requestContext, $moduleRoutingResponse, $routerOptions, $logger); |
|
63 | + $sfRouterWrapper = new SymfonyRouterWrapper($sfRouter); |
|
64 | + $chainRouter->add($sfRouterWrapper); |
|
65 | + break; |
|
66 | 66 | |
67 | - // @todo - move this to a separate method() |
|
68 | - case $moduleRoutingResponse instanceof AuraRouter: |
|
69 | - $auraRouterWrapper = new AuraRouterWrapper($moduleRoutingResponse); |
|
70 | - $chainRouter->add($auraRouterWrapper); |
|
71 | - break; |
|
67 | + // @todo - move this to a separate method() |
|
68 | + case $moduleRoutingResponse instanceof AuraRouter: |
|
69 | + $auraRouterWrapper = new AuraRouterWrapper($moduleRoutingResponse); |
|
70 | + $chainRouter->add($auraRouterWrapper); |
|
71 | + break; |
|
72 | 72 | |
73 | - // @todo - move this to a separate method() |
|
74 | - case $moduleRoutingResponse instanceof LaravelRouter: |
|
75 | - $laravelRequest = new LaravelRequest(); |
|
76 | - $laravelUrlGenerator = new LaravelUrlGenerator($moduleRoutingResponse->getRoutes(), $laravelRequest); |
|
77 | - $laravelRouterWrapper = new LaravelRouterWrapper( |
|
78 | - $moduleRoutingResponse, $laravelRequest, $laravelUrlGenerator |
|
79 | - ); |
|
80 | - // @todo - solve this problem |
|
73 | + // @todo - move this to a separate method() |
|
74 | + case $moduleRoutingResponse instanceof LaravelRouter: |
|
75 | + $laravelRequest = new LaravelRequest(); |
|
76 | + $laravelUrlGenerator = new LaravelUrlGenerator($moduleRoutingResponse->getRoutes(), $laravelRequest); |
|
77 | + $laravelRouterWrapper = new LaravelRouterWrapper( |
|
78 | + $moduleRoutingResponse, $laravelRequest, $laravelUrlGenerator |
|
79 | + ); |
|
80 | + // @todo - solve this problem |
|
81 | 81 | // $laravelRouterWrapper->setModuleName($this->getName()); |
82 | - $chainRouter->add($laravelRouterWrapper); |
|
83 | - break; |
|
82 | + $chainRouter->add($laravelRouterWrapper); |
|
83 | + break; |
|
84 | 84 | |
85 | - case $moduleRoutingResponse instanceof FastRouteWrapper: |
|
86 | - $chainRouter->add($moduleRoutingResponse); |
|
87 | - break; |
|
85 | + case $moduleRoutingResponse instanceof FastRouteWrapper: |
|
86 | + $chainRouter->add($moduleRoutingResponse); |
|
87 | + break; |
|
88 | 88 | |
89 | - default: |
|
90 | - throw new \Exception('Unexpected routes value return from module: ' . $moduleName . |
|
91 | - '. found value of type: ' . gettype($moduleRoutingResponse)); |
|
89 | + default: |
|
90 | + throw new \Exception('Unexpected routes value return from module: ' . $moduleName . |
|
91 | + '. found value of type: ' . gettype($moduleRoutingResponse)); |
|
92 | 92 | } |
93 | 93 | } |
94 | 94 |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | $logger = $serviceLocator->has('Logger') ? $serviceLocator->get('Logger') : null; |
51 | 51 | |
52 | 52 | $chainRouter = new ChainRouter($logger); |
53 | - if($serviceLocator->has('RoutingCache')) { |
|
53 | + if ($serviceLocator->has('RoutingCache')) { |
|
54 | 54 | $chainRouter->setCache($serviceLocator->get('RoutingCache')); |
55 | 55 | } |
56 | 56 | |
@@ -91,8 +91,8 @@ discard block |
||
91 | 91 | break; |
92 | 92 | |
93 | 93 | default: |
94 | - throw new \Exception('Unexpected routes value return from module: ' . $moduleName . |
|
95 | - '. found value of type: ' . gettype($moduleRoutingResponse)); |
|
94 | + throw new \Exception('Unexpected routes value return from module: '.$moduleName. |
|
95 | + '. found value of type: '.gettype($moduleRoutingResponse)); |
|
96 | 96 | } |
97 | 97 | } |
98 | 98 |
@@ -402,7 +402,7 @@ discard block |
||
402 | 402 | /** |
403 | 403 | * @note Added for compatibility with Symfony's HttpKernel\Kernel. |
404 | 404 | * |
405 | - * @return null|ServiceManager |
|
405 | + * @return ServiceManager |
|
406 | 406 | */ |
407 | 407 | public function getContainer() |
408 | 408 | { |
@@ -650,7 +650,7 @@ discard block |
||
650 | 650 | /** |
651 | 651 | * Logs with an arbitrary level. |
652 | 652 | * |
653 | - * @param mixed $level |
|
653 | + * @param string $level |
|
654 | 654 | * @param string $message |
655 | 655 | * @param array $context |
656 | 656 | */ |
@@ -172,7 +172,7 @@ discard block |
||
172 | 172 | return $this; |
173 | 173 | } |
174 | 174 | |
175 | - if($this->isDebug()) { |
|
175 | + if ($this->isDebug()) { |
|
176 | 176 | ExceptionHandler::register(true, 'UTF-8', 'PPI Framework', self::VERSION, true); |
177 | 177 | } |
178 | 178 | |
@@ -230,7 +230,7 @@ discard block |
||
230 | 230 | $response = $this->dispatch($request, $response); |
231 | 231 | } catch (ResourceNotFoundException $e) { |
232 | 232 | |
233 | - if($this->symfonyKernel === null) { |
|
233 | + if ($this->symfonyKernel === null) { |
|
234 | 234 | throw $e; |
235 | 235 | } |
236 | 236 | $response = $this->symfonyKernel->handle($cleanRequest); |
@@ -376,7 +376,7 @@ discard block |
||
376 | 376 | public function getRootDir() |
377 | 377 | { |
378 | 378 | if (null === $this->rootDir) { |
379 | - $this->rootDir = realpath(getcwd() . '/app'); |
|
379 | + $this->rootDir = realpath(getcwd().'/app'); |
|
380 | 380 | } |
381 | 381 | |
382 | 382 | return $this->rootDir; |
@@ -465,7 +465,7 @@ discard block |
||
465 | 465 | */ |
466 | 466 | public function getCacheDir() |
467 | 467 | { |
468 | - return $this->rootDir . '/cache/' . $this->environment; |
|
468 | + return $this->rootDir.'/cache/'.$this->environment; |
|
469 | 469 | } |
470 | 470 | |
471 | 471 | /** |
@@ -477,7 +477,7 @@ discard block |
||
477 | 477 | */ |
478 | 478 | public function getLogDir() |
479 | 479 | { |
480 | - return $this->rootDir . '/logs'; |
|
480 | + return $this->rootDir.'/logs'; |
|
481 | 481 | } |
482 | 482 | |
483 | 483 | /** |
@@ -500,8 +500,8 @@ discard block |
||
500 | 500 | public function getConfigManager() |
501 | 501 | { |
502 | 502 | if (null === $this->configManager) { |
503 | - $cachePath = $this->getCacheDir() . '/application-config-cache.' . $this->getName() . '.php'; |
|
504 | - $this->configManager = new ConfigManager($cachePath, !$this->debug, $this->rootDir . '/config'); |
|
503 | + $cachePath = $this->getCacheDir().'/application-config-cache.'.$this->getName().'.php'; |
|
504 | + $this->configManager = new ConfigManager($cachePath, !$this->debug, $this->rootDir.'/config'); |
|
505 | 505 | } |
506 | 506 | |
507 | 507 | return $this->configManager; |
@@ -421,6 +421,10 @@ |
||
421 | 421 | return $questionHelper->ask($input, $output, $question); |
422 | 422 | } |
423 | 423 | |
424 | + /** |
|
425 | + * @param InputInterface $input |
|
426 | + * @param OutputInterface $output |
|
427 | + */ |
|
424 | 428 | private function chooseTemplatingEngine($input, $output) |
425 | 429 | { |
426 | 430 | $tplQuestion = new ChoiceQuestion('Choose your templating engine [php]', |
@@ -561,13 +561,13 @@ |
||
561 | 561 | $tokenMap = []; |
562 | 562 | |
563 | 563 | switch($routingEngine) { |
564 | - case self::ROUTING_ENGINE_SYMFONY: |
|
565 | - $tokenMap['[ROUTING_TRAIT]'] = 'use \PPI\Framework\Module\Routing\SymfonyTrait;'; |
|
566 | - break; |
|
564 | + case self::ROUTING_ENGINE_SYMFONY: |
|
565 | + $tokenMap['[ROUTING_TRAIT]'] = 'use \PPI\Framework\Module\Routing\SymfonyTrait;'; |
|
566 | + break; |
|
567 | 567 | |
568 | - default: |
|
569 | - throw new \Exception('Unimplemented routing engine: ' . $routingEngine); |
|
570 | - break; |
|
568 | + default: |
|
569 | + throw new \Exception('Unimplemented routing engine: ' . $routingEngine); |
|
570 | + break; |
|
571 | 571 | } |
572 | 572 | |
573 | 573 | return $tokenMap; |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | protected function execute(InputInterface $input, OutputInterface $output) |
183 | 183 | { |
184 | 184 | $this->moduleName = $input->getArgument('name'); |
185 | - $this->moduleDir = $this->modulesDir . DIRECTORY_SEPARATOR . $this->moduleName; |
|
185 | + $this->moduleDir = $this->modulesDir.DIRECTORY_SEPARATOR.$this->moduleName; |
|
186 | 186 | |
187 | 187 | // Acquire Module Information |
188 | 188 | $this->askQuestions($input, $output); |
@@ -199,12 +199,12 @@ discard block |
||
199 | 199 | |
200 | 200 | $tokens['[MODULE_NAME]'] = $this->moduleName; |
201 | 201 | |
202 | - if(null !== $this->tplEngine && $this->isValidTemplatingEngine($this->tplEngine)) { |
|
202 | + if (null !== $this->tplEngine && $this->isValidTemplatingEngine($this->tplEngine)) { |
|
203 | 203 | $this->processTemplatingFiles(); |
204 | 204 | $output->writeln(sprintf("Templating: <info>%s</info>", $this->tplEngine)); |
205 | 205 | } |
206 | 206 | |
207 | - if($this->isValidRoutingEngine($this->routingEngine)) { |
|
207 | + if ($this->isValidRoutingEngine($this->routingEngine)) { |
|
208 | 208 | $this->processRoutingFiles($tokenizedFiles, $tokens); |
209 | 209 | $output->writeln(sprintf("Router: <info>%s</info>", $this->routingEngine)); |
210 | 210 | } else { |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | protected function replaceTokensInFiles($moduleDir, $files, $tokens) |
251 | 251 | { |
252 | 252 | foreach ($files as $file) { |
253 | - $file = $moduleDir . DIRECTORY_SEPARATOR . $file; |
|
253 | + $file = $moduleDir.DIRECTORY_SEPARATOR.$file; |
|
254 | 254 | if (!is_writeable($file)) { |
255 | 255 | throw new \InvalidArgumentException(sprintf('File %s is not writeable', $file)); |
256 | 256 | } |
@@ -268,8 +268,8 @@ discard block |
||
268 | 268 | protected function copyFiles($skeletonDir, $moduleDir, $files) |
269 | 269 | { |
270 | 270 | foreach ($files as $file) { |
271 | - $srcFile = $skeletonDir . DIRECTORY_SEPARATOR . $file; |
|
272 | - $dstFile = $moduleDir . DIRECTORY_SEPARATOR . $file; |
|
271 | + $srcFile = $skeletonDir.DIRECTORY_SEPARATOR.$file; |
|
272 | + $dstFile = $moduleDir.DIRECTORY_SEPARATOR.$file; |
|
273 | 273 | if (!file_exists($srcFile)) { |
274 | 274 | throw new \InvalidArgumentException(sprintf('File does not exist: %s', $srcFile)); |
275 | 275 | } |
@@ -296,7 +296,7 @@ discard block |
||
296 | 296 | |
297 | 297 | // Create base structure |
298 | 298 | foreach ($this->coreDirs as $coreDir) { |
299 | - $tmpDir = $moduleDir . DIRECTORY_SEPARATOR . $coreDir; |
|
299 | + $tmpDir = $moduleDir.DIRECTORY_SEPARATOR.$coreDir; |
|
300 | 300 | @mkdir($tmpDir); |
301 | 301 | } |
302 | 302 | } |
@@ -316,11 +316,11 @@ discard block |
||
316 | 316 | $this->modulesDir = $questionHelper->ask($input, $output, $modulesDirQuestion); |
317 | 317 | } |
318 | 318 | |
319 | - if($this->askForTemplating($input, $output)) { |
|
319 | + if ($this->askForTemplating($input, $output)) { |
|
320 | 320 | $this->chooseTemplatingEngine($input, $output); |
321 | 321 | } |
322 | 322 | |
323 | - if($this->askForRouting($input, $output)) { |
|
323 | + if ($this->askForRouting($input, $output)) { |
|
324 | 324 | $this->chooseRouter($input, $output); |
325 | 325 | } |
326 | 326 | } |
@@ -434,7 +434,7 @@ discard block |
||
434 | 434 | ] |
435 | 435 | ); |
436 | 436 | $tplQuestion->setErrorMessage('Templating engine %s is invalid.'); |
437 | - if(99 !== ($tplEngine = $this->getHelper('question')->ask($input, $output, $tplQuestion))) { |
|
437 | + if (99 !== ($tplEngine = $this->getHelper('question')->ask($input, $output, $tplQuestion))) { |
|
438 | 438 | $this->tplEngine = $tplEngine; |
439 | 439 | } |
440 | 440 | } |
@@ -454,7 +454,7 @@ discard block |
||
454 | 454 | // @todo - test question when you don't choose any option, or an invalid one (like -1) |
455 | 455 | $routingQuestion->setErrorMessage('Routing engine %s is invalid.'); |
456 | 456 | $chosenRouter = $this->getHelper('question')->ask($input, $output, $routingQuestion); |
457 | - if(99 == $chosenRouter) { |
|
457 | + if (99 == $chosenRouter) { |
|
458 | 458 | $chosenRouter = 'NullRouter'; |
459 | 459 | } |
460 | 460 | $this->routingEngine = $chosenRouter; |
@@ -462,8 +462,8 @@ discard block |
||
462 | 462 | |
463 | 463 | private function getTemplatingFilesFromEngine($tplEngine) |
464 | 464 | { |
465 | - if(!isset($this->tplEngineFilesMap[$tplEngine])) { |
|
466 | - throw new \InvalidArgumentException('Invalid templating engine specified for map files: ' . $tplEngine); |
|
465 | + if (!isset($this->tplEngineFilesMap[$tplEngine])) { |
|
466 | + throw new \InvalidArgumentException('Invalid templating engine specified for map files: '.$tplEngine); |
|
467 | 467 | } |
468 | 468 | } |
469 | 469 | |
@@ -472,7 +472,7 @@ discard block |
||
472 | 472 | $tplFiles = $this->getTemplatingFilesFromEngine($this->tplEngine); |
473 | 473 | |
474 | 474 | // Copy core templating files over |
475 | - foreach($this->tplEngineCoreFiles as $coreFile) { |
|
475 | + foreach ($this->tplEngineCoreFiles as $coreFile) { |
|
476 | 476 | $tplFiles[] = $coreFile; |
477 | 477 | } |
478 | 478 | |
@@ -499,18 +499,18 @@ discard block |
||
499 | 499 | private function processRoutingFiles($tokenizedFiles, $tokens) |
500 | 500 | { |
501 | 501 | |
502 | - if(!isset($this->routingEngineFilesMap[$this->routingEngine])) { |
|
503 | - throw new \Exception('Routing engine not found in routing files map: ' . $this->routingEngine); |
|
502 | + if (!isset($this->routingEngineFilesMap[$this->routingEngine])) { |
|
503 | + throw new \Exception('Routing engine not found in routing files map: '.$this->routingEngine); |
|
504 | 504 | } |
505 | 505 | |
506 | 506 | // Copy routing files over |
507 | 507 | $routingFiles = $this->routingEngineFilesMap[$this->routingEngine]; |
508 | 508 | |
509 | 509 | // If a valid routing engine and that's not null router |
510 | - if($this->routingEngine !== 99) { |
|
510 | + if ($this->routingEngine !== 99) { |
|
511 | 511 | // Create core routing directories |
512 | - foreach($this->routingEngineCoreFiles as $coreFile) { |
|
513 | - @mkdir($this->moduleDir . DIRECTORY_SEPARATOR . $coreFile); |
|
512 | + foreach ($this->routingEngineCoreFiles as $coreFile) { |
|
513 | + @mkdir($this->moduleDir.DIRECTORY_SEPARATOR.$coreFile); |
|
514 | 514 | } |
515 | 515 | } |
516 | 516 | |
@@ -537,8 +537,8 @@ discard block |
||
537 | 537 | // Prepare the fastroute route file |
538 | 538 | if ($this->routingEngine === self::ROUTING_ENGINE_FASTROUTE) { |
539 | 539 | rename( |
540 | - $moduleDir . DIRECTORY_SEPARATOR . $routingFiles[0], |
|
541 | - str_replace('IndexInvoke', 'Index', $moduleDir . DIRECTORY_SEPARATOR . $routingFiles[0] |
|
540 | + $moduleDir.DIRECTORY_SEPARATOR.$routingFiles[0], |
|
541 | + str_replace('IndexInvoke', 'Index', $moduleDir.DIRECTORY_SEPARATOR.$routingFiles[0] |
|
542 | 542 | )); |
543 | 543 | } |
544 | 544 | } |
@@ -560,13 +560,13 @@ discard block |
||
560 | 560 | |
561 | 561 | $tokenMap = []; |
562 | 562 | |
563 | - switch($routingEngine) { |
|
563 | + switch ($routingEngine) { |
|
564 | 564 | case self::ROUTING_ENGINE_SYMFONY: |
565 | 565 | $tokenMap['[ROUTING_TRAIT]'] = 'use \PPI\Framework\Module\Routing\SymfonyTrait;'; |
566 | 566 | break; |
567 | 567 | |
568 | 568 | default: |
569 | - throw new \Exception('Unimplemented routing engine: ' . $routingEngine); |
|
569 | + throw new \Exception('Unimplemented routing engine: '.$routingEngine); |
|
570 | 570 | break; |
571 | 571 | } |
572 | 572 |
@@ -53,9 +53,9 @@ |
||
53 | 53 | // this throws an exception if there is no such module |
54 | 54 | $msg = sprintf('Unable to find controller "%s:%s" - module alias "%s" does not exist.', $moduleName, $controller, $moduleAlias); |
55 | 55 | } else { |
56 | - $class = $module->getNamespace() . '\\Controller\\' . $controller; |
|
56 | + $class = $module->getNamespace().'\\Controller\\'.$controller; |
|
57 | 57 | if (class_exists($class)) { |
58 | - return $class . '::' . $action . 'Action'; |
|
58 | + return $class.'::'.$action.'Action'; |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | $msg = sprintf('Unable to find controller "%s:%s" - class "%s" does not exist.', $moduleName, $controller, $class); |