Skip to content

Commit

Permalink
ci: routes have been validated to display routes from the console
Browse files Browse the repository at this point in the history
  • Loading branch information
Sleon4 committed Jul 11, 2023
1 parent e4a66c9 commit 3b0530f
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions app/Console/Framework/Route/RouteListCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Helper\{ Table, TableCell, TableSeparator };
use Symfony\Component\Console\Helper\Table;
use Symfony\Component\Console\Helper\TableCell;
use Symfony\Component\Console\Helper\TableSeparator;

class RouteListCommand extends Command {

Expand All @@ -32,6 +34,7 @@ protected function execute(InputInterface $input, OutputInterface $output) {
array_pop($routes);
$rules = require_once("./routes/rules.php");
$config_middleware = require_once("./config/middleware.php");
$config_middleware = [...$config_middleware['framework'], ...$config_middleware['app']];
$size = arr->of($routes)->length();
$cont = 0;
$rows = [];
Expand Down Expand Up @@ -76,12 +79,10 @@ protected function execute(InputInterface $input, OutputInterface $output) {
}

if ($method['handler']['controller'] != false) {
$controller = $transformNamespace($method['handler']['controller']['name']);

$rows[] = [
$this->warningOutput($keyMethods),
$route_url,
$controller,
$transformNamespace($method['handler']['controller']['name']),
$this->warningOutput($method['handler']['controller']['function']),
$this->errorOutput("false"),
];
Expand All @@ -92,12 +93,10 @@ protected function execute(InputInterface $input, OutputInterface $output) {
foreach ($config_middleware as $middlewareClass => $middlewareMethods) {
foreach ($middlewareMethods as $middlewareItem => $item) {
if ($filter === $item['name']) {
$middleware = $transformNamespace($middlewareClass);

$rows[] = [
$this->infoOutput("MIDDLEWARE:"),
$this->infoOutput($filter),
$middleware,
$transformNamespace($middlewareClass),
$this->warningOutput($item['method']),
$this->errorOutput("false")
];
Expand All @@ -111,12 +110,10 @@ protected function execute(InputInterface $input, OutputInterface $output) {
if (isset($rules[$keyMethods][$route_url])) {
foreach ($rules[$keyMethods][$route_url] as $key_uri_rule => $class_rule) {
$required_param = $class_rule::$disabled === false ? "REQUIRED" : "OPTIONAL";
$class_namespace = $transformNamespace($class_rule);

$rows[] = [
$this->successOutput("PARAM:"),
$this->successOutput($class_rule::$field . " ({$required_param})"),
$class_namespace,
$transformNamespace($class_rule),
$this->warningOutput("passes"),
$this->errorOutput("false")
];
Expand All @@ -136,7 +133,7 @@ protected function execute(InputInterface $input, OutputInterface $output) {
->setHeaderTitle($this->successOutput('ROUTES'))
->setFooterTitle(
$size > 1
? $this->successOutput(" showing [" . $size . "] routes ")
? $this->successOutput(" showing [{$size}] routes ")
: ($size === 1
? $this->successOutput(" showing a single route ")
: $this->successOutput(" no routes available ")
Expand Down

0 comments on commit 3b0530f

Please sign in to comment.