/** * @param InputInterface $input * @param OutputInterface $output */ protected function execute(InputInterface $input, OutputInterface $output) { $app = $this->getApplication(); $table = $app->getHelperSet()->get('table'); $table->setLayout(TableHelper::LAYOUT_BORDERLESS); $rules = new RuleBook(); $rules->load($this->conf->get('routes'), true); // foreach ($this->conf->get('routes') as $url => $params) { foreach ($rules->all() as $rule) { $template = $rule->getTemplate(); $params = $rule->getInformation(); $method = '*'; $generator = ''; if (isset($params['method'])) { $method = $params['method']; unset($params['method']); } if (isset($params['_generator'])) { $generator = $params['_generator']; unset($params['_generator']); } // json string clean up $info = str_replace(['":"', '","', '{"', '"}'], [': ', ', ', '', ''], json_encode($params, JSON_UNESCAPED_SLASHES)); $table->addRow([$generator, strtolower($method), $template, $info]); } $table->render($output); }
/** * @expectedException Efficio\Http\Error\DuplicateRuleException */ public function testLoadingDuplicatesTriggersError() { $this->rulebook->load(['/users' => []]); $this->rulebook->load(['/users' => []]); }
use Efficio\Http\Request; use Efficio\Http\Response; use Efficio\Http\RuleBook; use Efficio\Http\Status; use Exception; use Fabrico\Renderer; use Fabrico\Runtime\Instance; require 'vendor/autoload.php'; $app = Instance::create(); $conf = $app->getConfiguration(); $res = new Response(); $req = new Request(); $req->importFromGlobals(); $rules = new RuleBook(); $rules->load($conf->get('routes'), true); $app->setRuleBook($rules); $renderer = new Renderer(); $renderer->handlers($conf->get('app:views:renderers')); $app->setRenderer($renderer); try { if (!$app->route($req, $res)) { $res->setStatusCode(Status::NOT_FOUND); $res->setContentType(Response::HTML); $res->setContent(file_get_contents('public/404.html')); } } catch (Exception $ex) { // reset headers in case something like a redirect header was set before // the exception was thrown. we don't want to send any of those, or // anything else other than a status code and the error page content // TODO: update Http and Utilitatis to do this: