public function pipe($path, $middleware = null)
{
if (null === $middleware && is_callable($path)) {
$middleware = $path;
$path = '/';
}
// Ensure we have a valid handler
if (!is_callable($middleware)) {
throw new InvalidArgumentException('Middleware must be callable');
}
$this->pipeline->enqueue(new Route($this->normalizePipePath($path), $middleware));
// @todo Trigger event here with route details?
return $this;
}
<?php use Phly\Conduit\MiddlewarePipe; use Application\NotFound; return call_user_func(function () { $services = (include 'config/services.php'); $app = new MiddlewarePipe(); // basics eg.redirect // site 1 $app->pipe($services->get('Sample\\Module')); // errors $app->pipe(new NotFound()); // authentication // error handler $app->pipe($services->get('ErrorHandler')); return $app; });