Permalink
Browse files

Update symfony/console.

  • Loading branch information...
piotrooo committed Feb 20, 2018
1 parent c369a90 commit be40b886aff21cecc73963b04bb9b85edd6a86c3
Showing with 53 additions and 43 deletions.
  1. +18 −17 bin/RoutesCommand.php
  2. +1 −1 composer.json
  3. +34 −25 composer.lock
@@ -13,6 +13,7 @@
use Ouzo\Utilities\Arrays;
use Ouzo\Utilities\Path;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Helper\Table;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
@@ -22,11 +23,11 @@ class RoutesCommand extends Command
/**
* @var InputInterface
*/
private $_input;
private $input;
/**
* @var OutputInterface
*/
private $_output;
private $output;
public function configure()
{
@@ -40,8 +41,8 @@ public function configure()
public function execute(InputInterface $input, OutputInterface $output)
{
$this->_input = $input;
$this->_output = $output;
$this->input = $input;
$this->output = $output;
$generateOptionFunctionMap = [
"generate-php" => "generatePhpHelper",
"generate-js" => "generateJsHelper",
@@ -80,55 +81,55 @@ private function generatePhpHelper()
{
$routesPhpHelperPath = Path::join(ROOT_PATH, ApplicationPaths::getHelperPath(), 'GeneratedUriHelper.php');
if (UriHelperGenerator::generate()->saveToFile($routesPhpHelperPath) !== false) {
$this->_output->writeln("File with PHP uri helpers is generated in <info>$routesPhpHelperPath</info>");
$this->output->writeln("File with PHP uri helpers is generated in <info>$routesPhpHelperPath</info>");
}
}
private function generateJsHelper()
{
$routesJSHelperPath = $this->_input->getOption('path');
$routesJSHelperPath = $this->input->getOption('path');
$routesJSHelperPath = Path::join($routesJSHelperPath, 'generated_uri_helper.js');
if (JsUriHelperGenerator::generate()->saveToFile($routesJSHelperPath) !== false) {
$this->_output->writeln("File with JS uri helpers is generated in <info>$routesJSHelperPath</info>");
$this->output->writeln("File with JS uri helpers is generated in <info>$routesJSHelperPath</info>");
}
}
private function controller()
{
$controller = $this->_input->getOption('controller');
$this->_renderRoutes(Route::getRoutesForController($controller));
$controller = $this->input->getOption('controller');
$this->renderRoutes(Route::getRoutesForController($controller));
}
private function all()
{
$this->_renderRoutes(Route::getRoutes());
$this->renderRoutes(Route::getRoutes());
}
private function _renderRoutes($routes = [])
private function renderRoutes($routes = [])
{
$table = $this->getHelper('table');
$table = new Table($this->output);
$table->setHeaders(['URL Helper', 'HTTP Verb', 'Path', 'Controller#Action']);
foreach ($routes as $route) {
$method = $this->_getRuleMethod($route);
$method = $this->getRuleMethod($route);
$action = $route->getAction() ? '#' . $route->getAction() : $route->getAction();
$controllerAction = $route->getController() . $action;
$table->addRow([$route->getName(), $method, $route->getUri(), $controllerAction]);
$this->_printExceptIfExists($route, $table);
$this->printExceptIfExists($route, $table);
}
$table->render($this->_output);
$table->render();
}
private function _getRuleMethod(RouteRule $rule)
private function getRuleMethod(RouteRule $rule)
{
if (!$rule->isActionRequired()) {
return 'ALL';
}
return is_array($rule->getMethod()) ? 'ANY' : $rule->getMethod();
}
private function _printExceptIfExists(RouteRule $rule, $table)
private function printExceptIfExists(RouteRule $rule, Table $table)
{
$except = $rule->getExcept();
if ($except) {
@@ -37,7 +37,7 @@
},
"require": {
"d11wtq/boris": "1.0.8",
"symfony/console": "v3.2.*",
"symfony/console": "^3.4",
"filp/whoops": "2.1.*",
"psr/log": "^1.0"
},

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

0 comments on commit be40b88

Please sign in to comment.