Ejemplo n.º 1
0
    fwrite(STDERR, $err);
    exit(1);
}
$routeStr = $argv[1];
$uri = $factory->createUri($routeStr);
$key = $uri->getRouteKey();
$parts = explode('.', $key);
$key = current($parts);
$format = strtolower(next($parts));
if (empty($format)) {
    $format = 'text';
}
$input = $factory->createInputFromSuperGlobals($uri);
$route = $factory->createRouteDetail($key);
if (!$route instanceof MvcRouteDetailInterface) {
    $err = "could not resolve route detail for -({$key})";
    throw new LogicException($err);
}
$context = $factory->createContext($key, $input);
$init->runStartupTasks($route);
$viewBuilder = $factory->createViewBuilder();
$viewBuilder->setupView($context, $route, $format);
$front = $factory->createFront();
$context = $front->run($context);
$content = $viewBuilder->composeView($context, $route, $format);
$code = $context->getExitCode();
if ($code >= 200 || $code < 300) {
    $code = 0;
}
fwrite(STDOUT, $content);
exit($context->getExitCode());