@@ -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 | |
@@ -87,8 +87,8 @@ |
||
| 87 | 87 | break; |
| 88 | 88 | |
| 89 | 89 | default: |
| 90 | - throw new \Exception('Unexpected routes value return from module: ' . $moduleName . |
|
| 91 | - '. found value of type: ' . gettype($moduleRoutingResponse)); |
|
| 90 | + throw new \Exception('Unexpected routes value return from module: '.$moduleName. |
|
| 91 | + '. found value of type: '.gettype($moduleRoutingResponse)); |
|
| 92 | 92 | } |
| 93 | 93 | } |
| 94 | 94 | |
@@ -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 | */ |
@@ -343,7 +343,7 @@ discard block |
||
| 343 | 343 | public function getRootDir() |
| 344 | 344 | { |
| 345 | 345 | if (null === $this->rootDir) { |
| 346 | - $this->rootDir = realpath(getcwd() . '/app'); |
|
| 346 | + $this->rootDir = realpath(getcwd().'/app'); |
|
| 347 | 347 | } |
| 348 | 348 | |
| 349 | 349 | return $this->rootDir; |
@@ -432,7 +432,7 @@ discard block |
||
| 432 | 432 | */ |
| 433 | 433 | public function getCacheDir() |
| 434 | 434 | { |
| 435 | - return $this->rootDir . '/cache/' . $this->environment; |
|
| 435 | + return $this->rootDir.'/cache/'.$this->environment; |
|
| 436 | 436 | } |
| 437 | 437 | |
| 438 | 438 | /** |
@@ -444,7 +444,7 @@ discard block |
||
| 444 | 444 | */ |
| 445 | 445 | public function getLogDir() |
| 446 | 446 | { |
| 447 | - return $this->rootDir . '/logs'; |
|
| 447 | + return $this->rootDir.'/logs'; |
|
| 448 | 448 | } |
| 449 | 449 | |
| 450 | 450 | /** |
@@ -467,8 +467,8 @@ discard block |
||
| 467 | 467 | public function getConfigManager() |
| 468 | 468 | { |
| 469 | 469 | if (null === $this->configManager) { |
| 470 | - $cachePath = $this->getCacheDir() . '/application-config-cache.' . $this->getName() . '.php'; |
|
| 471 | - $this->configManager = new ConfigManager($cachePath, !$this->debug, $this->rootDir . '/config'); |
|
| 470 | + $cachePath = $this->getCacheDir().'/application-config-cache.'.$this->getName().'.php'; |
|
| 471 | + $this->configManager = new ConfigManager($cachePath, !$this->debug, $this->rootDir.'/config'); |
|
| 472 | 472 | } |
| 473 | 473 | |
| 474 | 474 | 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; |
@@ -187,7 +187,7 @@ discard block |
||
| 187 | 187 | protected function execute(InputInterface $input, OutputInterface $output) |
| 188 | 188 | { |
| 189 | 189 | $this->moduleName = $input->getArgument('name'); |
| 190 | - $this->moduleDir = $this->modulesDir . DIRECTORY_SEPARATOR . $this->moduleName; |
|
| 190 | + $this->moduleDir = $this->modulesDir.DIRECTORY_SEPARATOR.$this->moduleName; |
|
| 191 | 191 | |
| 192 | 192 | // Acquire Module Information |
| 193 | 193 | $this->askQuestions($input, $output); |
@@ -204,12 +204,12 @@ discard block |
||
| 204 | 204 | |
| 205 | 205 | $tokens['[MODULE_NAME]'] = $this->moduleName; |
| 206 | 206 | |
| 207 | - if(null !== $this->tplEngine && $this->isValidTemplatingEngine($this->tplEngine)) { |
|
| 207 | + if (null !== $this->tplEngine && $this->isValidTemplatingEngine($this->tplEngine)) { |
|
| 208 | 208 | $this->processTemplatingFiles(); |
| 209 | 209 | $output->writeln(sprintf("Templating: <info>%s</info>", $this->tplEngine)); |
| 210 | 210 | } |
| 211 | 211 | |
| 212 | - if($this->isValidRoutingEngine($this->routingEngine)) { |
|
| 212 | + if ($this->isValidRoutingEngine($this->routingEngine)) { |
|
| 213 | 213 | $this->processRoutingFiles($tokenizedFiles, $tokens); |
| 214 | 214 | $output->writeln(sprintf("Router: <info>%s</info>", $this->routingEngine)); |
| 215 | 215 | } else { |
@@ -255,7 +255,7 @@ discard block |
||
| 255 | 255 | protected function replaceTokensInFiles($moduleDir, $files, $tokens) |
| 256 | 256 | { |
| 257 | 257 | foreach ($files as $file) { |
| 258 | - $file = $moduleDir . DIRECTORY_SEPARATOR . $file; |
|
| 258 | + $file = $moduleDir.DIRECTORY_SEPARATOR.$file; |
|
| 259 | 259 | if (!is_writeable($file)) { |
| 260 | 260 | throw new \InvalidArgumentException(sprintf('File %s is not writeable', $file)); |
| 261 | 261 | } |
@@ -273,8 +273,8 @@ discard block |
||
| 273 | 273 | protected function copyFiles($skeletonDir, $moduleDir, $files) |
| 274 | 274 | { |
| 275 | 275 | foreach ($files as $file) { |
| 276 | - $srcFile = $skeletonDir . DIRECTORY_SEPARATOR . $file; |
|
| 277 | - $dstFile = $moduleDir . DIRECTORY_SEPARATOR . $file; |
|
| 276 | + $srcFile = $skeletonDir.DIRECTORY_SEPARATOR.$file; |
|
| 277 | + $dstFile = $moduleDir.DIRECTORY_SEPARATOR.$file; |
|
| 278 | 278 | if (!file_exists($srcFile)) { |
| 279 | 279 | throw new \InvalidArgumentException(sprintf('File does not exist: %s', $srcFile)); |
| 280 | 280 | } |
@@ -301,7 +301,7 @@ discard block |
||
| 301 | 301 | |
| 302 | 302 | // Create base structure |
| 303 | 303 | foreach ($this->coreDirs as $coreDir) { |
| 304 | - $tmpDir = $moduleDir . DIRECTORY_SEPARATOR . $coreDir; |
|
| 304 | + $tmpDir = $moduleDir.DIRECTORY_SEPARATOR.$coreDir; |
|
| 305 | 305 | @mkdir($tmpDir); |
| 306 | 306 | } |
| 307 | 307 | } |
@@ -321,12 +321,12 @@ discard block |
||
| 321 | 321 | $this->modulesDir = $questionHelper->ask($input, $output, $modulesDirQuestion); |
| 322 | 322 | } |
| 323 | 323 | |
| 324 | - if($this->askForTemplating($input, $output)) { |
|
| 324 | + if ($this->askForTemplating($input, $output)) { |
|
| 325 | 325 | $this->chooseTemplatingEngine($input, $output); |
| 326 | 326 | } |
| 327 | 327 | |
| 328 | - if($this->askForContoller($input, $output)) { |
|
| 329 | - if($this->askForRouting($input, $output)) { |
|
| 328 | + if ($this->askForContoller($input, $output)) { |
|
| 329 | + if ($this->askForRouting($input, $output)) { |
|
| 330 | 330 | return $this->chooseRouter($input, $output); |
| 331 | 331 | } |
| 332 | 332 | } |
@@ -441,7 +441,7 @@ discard block |
||
| 441 | 441 | ] |
| 442 | 442 | ); |
| 443 | 443 | $tplQuestion->setErrorMessage('Templating engine %s is invalid.'); |
| 444 | - if(99 !== ($tplEngine = $this->getHelper('question')->ask($input, $output, $tplQuestion))) { |
|
| 444 | + if (99 !== ($tplEngine = $this->getHelper('question')->ask($input, $output, $tplQuestion))) { |
|
| 445 | 445 | $this->tplEngine = $tplEngine; |
| 446 | 446 | } |
| 447 | 447 | } |
@@ -467,7 +467,7 @@ discard block |
||
| 467 | 467 | // @todo - test question when you don't choose any option, or an invalid one (like -1) |
| 468 | 468 | $routingQuestion->setErrorMessage('Routing engine %s is invalid.'); |
| 469 | 469 | $chosenRouter = $this->getHelper('question')->ask($input, $output, $routingQuestion); |
| 470 | - if(99 == $chosenRouter) { |
|
| 470 | + if (99 == $chosenRouter) { |
|
| 471 | 471 | $chosenRouter = 'NullRouter'; |
| 472 | 472 | } |
| 473 | 473 | $this->routingEngine = $chosenRouter; |
@@ -480,8 +480,8 @@ discard block |
||
| 480 | 480 | */ |
| 481 | 481 | private function getTemplatingFilesFromEngine($tplEngine) |
| 482 | 482 | { |
| 483 | - if(!isset($this->tplEngineFilesMap[$tplEngine])) { |
|
| 484 | - throw new \InvalidArgumentException('Invalid templating engine specified for map files: ' . $tplEngine); |
|
| 483 | + if (!isset($this->tplEngineFilesMap[$tplEngine])) { |
|
| 484 | + throw new \InvalidArgumentException('Invalid templating engine specified for map files: '.$tplEngine); |
|
| 485 | 485 | } |
| 486 | 486 | } |
| 487 | 487 | |
@@ -493,7 +493,7 @@ discard block |
||
| 493 | 493 | $tplFiles = $this->getTemplatingFilesFromEngine($this->tplEngine); |
| 494 | 494 | |
| 495 | 495 | // Copy core templating files over |
| 496 | - foreach($this->tplEngineCoreFiles as $coreFile) { |
|
| 496 | + foreach ($this->tplEngineCoreFiles as $coreFile) { |
|
| 497 | 497 | $tplFiles[] = $coreFile; |
| 498 | 498 | } |
| 499 | 499 | |
@@ -522,18 +522,18 @@ discard block |
||
| 522 | 522 | private function processRoutingFiles($tokenizedFiles, $tokens) |
| 523 | 523 | { |
| 524 | 524 | |
| 525 | - if(!isset($this->routingEngineFilesMap[$this->routingEngine])) { |
|
| 526 | - throw new \Exception('Routing engine not found in routing files map: ' . $this->routingEngine); |
|
| 525 | + if (!isset($this->routingEngineFilesMap[$this->routingEngine])) { |
|
| 526 | + throw new \Exception('Routing engine not found in routing files map: '.$this->routingEngine); |
|
| 527 | 527 | } |
| 528 | 528 | |
| 529 | 529 | // Copy routing files over |
| 530 | 530 | $routingFiles = $this->routingEngineFilesMap[$this->routingEngine]; |
| 531 | 531 | |
| 532 | 532 | // If a valid routing engine and that's not null router |
| 533 | - if($this->routingEngine !== 99) { |
|
| 533 | + if ($this->routingEngine !== 99) { |
|
| 534 | 534 | // Create core routing directories |
| 535 | - foreach($this->routingEngineCoreFiles as $coreFile) { |
|
| 536 | - @mkdir($this->moduleDir . DIRECTORY_SEPARATOR . $coreFile); |
|
| 535 | + foreach ($this->routingEngineCoreFiles as $coreFile) { |
|
| 536 | + @mkdir($this->moduleDir.DIRECTORY_SEPARATOR.$coreFile); |
|
| 537 | 537 | } |
| 538 | 538 | } |
| 539 | 539 | |
@@ -560,8 +560,8 @@ discard block |
||
| 560 | 560 | // Prepare the fastroute route file |
| 561 | 561 | if ($this->routingEngine === self::ROUTING_ENGINE_FASTROUTE) { |
| 562 | 562 | rename( |
| 563 | - $moduleDir . DIRECTORY_SEPARATOR . $routingFiles[0], |
|
| 564 | - str_replace('IndexInvoke', 'Index', $moduleDir . DIRECTORY_SEPARATOR . $routingFiles[0] |
|
| 563 | + $moduleDir.DIRECTORY_SEPARATOR.$routingFiles[0], |
|
| 564 | + str_replace('IndexInvoke', 'Index', $moduleDir.DIRECTORY_SEPARATOR.$routingFiles[0] |
|
| 565 | 565 | )); |
| 566 | 566 | } |
| 567 | 567 | } |
@@ -591,13 +591,13 @@ discard block |
||
| 591 | 591 | |
| 592 | 592 | $tokenMap = []; |
| 593 | 593 | |
| 594 | - switch($routingEngine) { |
|
| 594 | + switch ($routingEngine) { |
|
| 595 | 595 | case self::ROUTING_ENGINE_SYMFONY: |
| 596 | 596 | $tokenMap['[ROUTING_TRAIT]'] = 'use \PPI\Framework\Module\Routing\SymfonyTrait;'; |
| 597 | 597 | break; |
| 598 | 598 | |
| 599 | 599 | default: |
| 600 | - throw new \Exception('Unimplemented routing engine: ' . $routingEngine); |
|
| 600 | + throw new \Exception('Unimplemented routing engine: '.$routingEngine); |
|
| 601 | 601 | break; |
| 602 | 602 | } |
| 603 | 603 | |
@@ -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); |