/var/www/aikonia/html/vendor/pecee/simple-router/src/Pecee/SimpleRouter/ClassLoader/ClassLoader.php
* @var bool
*/
protected $useDependencyInjection = false;
/**
* @var Container|null
*/
protected $container;
/**
* Load class
*
* @param string $class
* @return mixed
* @throws NotFoundHttpException
*/
public function loadClass(string $class)
{
if (class_exists($class) === false) {
throw new NotFoundHttpException(sprintf('Class "%s" does not exist', $class), 404);
}
if ($this->useDependencyInjection === true) {
$container = $this->getContainer();
if ($container !== null) {
try {
return $container->get($class);
} catch (\Exception $e) {
throw new NotFoundHttpException($e->getMessage(), (int)$e->getCode(), $e->getPrevious());
}
}
}
return new $class();
}
/**
* Load closure
*
* @param \Closure $closure
/var/www/aikonia/html/vendor/pecee/simple-router/src/Pecee/SimpleRouter/Route/Route.php
}
/* Render callback function */
if (\is_callable($callback) === true) {
$router->debug('Executing callback');
/* When the callback is a function */
return $router->getClassLoader()->loadClosure($callback, $parameters);
}
/* When the callback is a class + method */
$controller = explode('@', $callback);
$namespace = $this->getNamespace();
$className = ($namespace !== null && $controller[0][0] !== '\\') ? $namespace . '\\' . $controller[0] : $controller[0];
$router->debug('Loading class %s', $className);
$class = $router->getClassLoader()->loadClass($className);
if (\count($controller) === 1) {
$controller[1] = '__invoke';
}
$method = $controller[1];
if (method_exists($class, $method) === false) {
throw new NotFoundHttpException(sprintf('Method "%s" does not exist in class "%s"', $method, $className), 404);
}
$router->debug('Executing callback');
return \call_user_func_array([$class, $method], array_values($parameters));
}
protected function parseParameters($route, $url, $parameterRegex = null)
{
$regex = (strpos($route, $this->paramModifiers[0]) === false) ? null :
sprintf(
/var/www/aikonia/html/vendor/pecee/simple-router/src/Pecee/SimpleRouter/Router.php
$route->loadMiddleware($this->request, $this);
$route->addGetParametersModelToParameters($this->request);
$route->addFilesToParameters($this->request);
$route->addPostBodyToParameters($this->request);
$output = $this->handleRouteRewrite($key, $url);
if ($output !== null) {
return $output;
}
$methodNotAllowed = false;
$this->request->addLoadedRoute($route);
$this->fireEvents(EventHandler::EVENT_RENDER_ROUTE, [
'route' => $route,
]);
$output = $route->renderRoute($this->request, $this);
if ($output !== null) {
return $output;
}
$output = $this->handleRouteRewrite($key, $url);
if ($output !== null) {
return $output;
}
}
}
} catch (\Exception $e) {
$this->handleException($e);
}
if ($methodNotAllowed === true) {
$message = sprintf('Route "%s" or method "%s" not allowed.', $this->request->getUrl()->getPath(), $this->request->getMethod());
$this->handleException(new NotFoundHttpException($message, 403));
}
if (\count($this->request->getLoadedRoutes()) === 0) {
/var/www/aikonia/html/vendor/pecee/simple-router/src/Pecee/SimpleRouter/Router.php
* @throws \Exception
*/
public function start(): ?string
{
$this->debug('Router starting');
$this->fireEvents(EventHandler::EVENT_INIT);
$this->loadRoutes();
if ($this->csrfVerifier !== null) {
$this->fireEvents(EventHandler::EVENT_RENDER_CSRF, [
'csrfVerifier' => $this->csrfVerifier,
]);
/* Verify csrf token for request */
$this->csrfVerifier->handle($this->request);
}
$output = $this->routeRequest();
$this->fireEvents(EventHandler::EVENT_LOAD, [
'loadedRoutes' => $this->getRequest()->getLoadedRoutes(),
]);
$this->debug('Routing complete');
return $output;
}
/**
* Routes the request
*
* @return string|null
* @throws HttpException
* @throws \Exception
*/
public function routeRequest(): ?string
{
$this->debug('Routing request');
/var/www/aikonia/html/vendor/pecee/simple-router/src/Pecee/SimpleRouter/SimpleRouter.php
*/
protected static $response;
/**
* Router instance
* @var Router
*/
protected static $router;
/**
* Start routing
*
* @throws \Pecee\SimpleRouter\Exceptions\NotFoundHttpException
* @throws \Pecee\Http\Middleware\Exceptions\TokenMismatchException
* @throws HttpException
* @throws \Exception
*/
public static function start(): void
{
echo static::router()->start();
}
/**
* Start the routing an return array with debugging-information
*
* @return array
*/
public static function startDebug(): array
{
$routerOutput = null;
try {
ob_start();
static::router()->setDebugEnabled(true)->start();
$routerOutput = ob_get_contents();
ob_end_clean();
} catch (\Exception $e) {
}
// Try to parse library version
/var/www/aikonia/html/index.php
// ABOUT
SimpleRouter::get('/about', 'About@index')->setName('about');
SimpleRouter::get('/cast', 'About@index')->setName('about');
// LINKS
SimpleRouter::get('/links', 'Links@index')->setName('links');
});
// API
SimpleRouter::group(['prefix' => '/api', 'namespace' => 'library\controllers'], function()
{
// PAGE
SimpleRouter::post('/buffer/post', 'Page@post')->setName('postbuffer');
SimpleRouter::post('/page/images', 'Page@getImages')->setName('getimages');
// COMMENT
SimpleRouter::post('/comment/post', 'Comment@post')->setName('postcomment');
});
SimpleRouter::start();