/**
* Find the given view in the list of paths.
*
* @param string $path
* @return string
*
* @throws \InvalidArgumentException
*/
protected function findViewFile($path)
{
foreach ($this->getPossibleViewFiles($path) as $file) {
if ($this->files->exists($file)) {
return $file;
}
}
//
$name = str_replace(ROOTDIR, '', $path);
throw new \InvalidArgumentException("View [$name] not found.");
}
/**
* Get an array of possible view files.
*
* @param string $name
* @return array
*/
protected function getPossibleViewFiles($name)
{
return array_map(function($extension) use ($name)
{
return str_replace('/', DS, $name) .'.' .$extension;
}, $this->extensions);
}
/**
* Register an extension with the view finder.
*
Arguments
"View [app/Views/Site/polydor] not found."
public function __construct(Filesystem $files, array $extensions = null)
{
$this->files = $files;
if (isset($extensions)) {
$this->extensions = $extensions;
}
}
/**
* Get the fully qualified location of the view.
*
* @param string $name
* @return string
*/
public function find($name)
{
if (isset($this->views[$name])) return $this->views[$name];
return $this->views[$name] = $this->findViewFile($name);
}
/**
* Find the given view in the list of paths.
*
* @param string $path
* @return string
*
* @throws \InvalidArgumentException
*/
protected function findViewFile($path)
{
foreach ($this->getPossibleViewFiles($path) as $file) {
if ($this->files->exists($file)) {
return $file;
}
}
//
$name = str_replace(ROOTDIR, '', $path);
return $this->finder->find($path);
}
catch (InvalidArgumentException $e) {
// Do nothing.
}
}
// Try to find the View file on the base locations.
$viewPath = 'Views' .DS .$viewPath;
if (! empty($module)) {
$basePath = $this->getModulePath($module);
$path = $basePath .DS .$viewPath;
} else {
$path = APPDIR .$viewPath;
}
// Try to find the View file.
return $this->finder->find($path);
}
/**
* Find the Layout file.
*
* @param string $layout
* @param string $theme
*
* @return string
*/
protected function findLayoutFile($layout, $theme)
{
$language = $this->getLanguage();
// Prepare the Layout path.
$layoutPath = str_replace('/', DS, $layout);
// Calculate the path to Layouts in the requested Theme.
$basePath = $this->getThemePath($theme) .'Layouts';
* Create a View instance
*
* @param string $path
* @param mixed $data
* @param string|null $module
* @param string|null $theme
*
* @return \Nova\View\View
*/
public function make($view, $data = array(), $module = null, $theme = null)
{
if (isset($this->aliases[$view])) {
$view = $this->aliases[$view];
}
// Calculate the current Template name.
$theme = $theme ?: $this->getDefaultTheme();
// Get the View file path.
$path = $this->findViewFile($view, $module, $theme);
// Normalize the View name.
$domain = ! empty($module) ? $module : 'App';
$name = 'View/' .$domain .'::' .str_replace('/', '.', $view);
// Get the parsed View data.
$data = $this->parseData($data);
$this->callCreator($view = new View($this, $this->getEngineFromPath($path), $name, $path, $data));
return $view;
}
/**
* Create a Layout instance
*
* @param string $view
* @param string|null $theme
*
*/
public static function clearResolvedInstances()
{
static::$resolvedInstance = array();
}
/**
* Handle dynamic, static calls to the object.
*
* @param string $method
* @param array $args
* @return mixed
*/
public static function __callStatic($method, $args)
{
$accessor = static::getFacadeAccessor();
$instance = static::resolveFacadeInstance($accessor);
return call_user_func_array(array($instance, $method), $args);
}
}
*/
public static function clearResolvedInstances()
{
static::$resolvedInstance = array();
}
/**
* Handle dynamic, static calls to the object.
*
* @param string $method
* @param array $args
* @return mixed
*/
public static function __callStatic($method, $args)
{
$accessor = static::getFacadeAccessor();
$instance = static::resolveFacadeInstance($accessor);
return call_user_func_array(array($instance, $method), $args);
}
}
'content' => __('Content')
);
return Validator::make($data, $rules, $messages, $attributes);
}
/**
* Create and return a View instance.
*/
public function index()
{
//$request = Request::path();
return $this->getView()
->shares('title', 'Home')
->withUser($this->user);
}
public function biografie($slug)
{
return View::make('Site/' . $slug)
->shares('title', __('biografie ' . $slug))
->withUser($this->user);
}
public function singles()
{
return $this->getView()
->shares('title', __('Singles'));
}
public function albums()
{
return $this->getView()
->shares('title', __('Albums'));
}
public function verzamel()
{
return $this->getView()
->shares('title', __('Verzamelalbums'));
/**
* Execute an action on the controller.
*
* @param string $method
* @param array $params
* @return \Symfony\Component\HttpFoundation\Response
*/
public function callAction($method, $parameters)
{
$this->method = $method;
$this->parameters = $parameters;
// Execute the Before method.
$response = $this->before();
if (is_null($response)) {
// Execute the requested Method.
$response = call_user_func_array(array($this, $method), $parameters);
}
// Process the Response and return it.
return $this->after($response);
}
/**
* Handle calls to missing methods on the Controller.
*
* @param array $parameters
* @return mixed
*
* @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException
*/
public function missingMethod($parameters = array())
{
throw new NotFoundHttpException("Controller method not found.");
}
/**
/**
* Execute an action on the controller.
*
* @param string $method
* @param array $params
* @return \Symfony\Component\HttpFoundation\Response
*/
public function callAction($method, $parameters)
{
$this->method = $method;
$this->parameters = $parameters;
// Execute the Before method.
$response = $this->before();
if (is_null($response)) {
// Execute the requested Method.
$response = call_user_func_array(array($this, $method), $parameters);
}
// Process the Response and return it.
return $this->after($response);
}
/**
* Handle calls to missing methods on the Controller.
*
* @param array $parameters
* @return mixed
*
* @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException
*/
public function missingMethod($parameters = array())
{
throw new NotFoundHttpException("Controller method not found.");
}
/**
protected function makeController($controller)
{
Controller::setFilterer($this->filterer);
return $this->container->make($controller);
}
/**
* Call the given controller instance method.
*
* @param \Nova\Routing\Controller $instance
* @param \Nova\Routing\Route $route
* @param string $method
* @return mixed
*/
protected function call($instance, $route, $method)
{
$parameters = $route->parametersWithoutNulls();
return $instance->callAction($method, $parameters);
}
/**
* Call the "before" filters for the controller.
*
* @param \Nova\Routing\Controller $instance
* @param \Nova\Routing\Route $route
* @param \Nova\Http\Request $request
* @param string $method
* @return mixed
*/
protected function before($instance, $route, $request, $method)
{
foreach ($instance->getBeforeFilters() as $filter) {
if ($this->filterApplies($filter, $request, $method)) {
$response = $this->callFilter($filter, $route, $request);
if (! is_null($response)) return $response;
}
}
/**
* Dispatch a request to a given controller and method.
*
* @param \Nova\Routing\Route $route
* @param \Nova\Http\Request $request
* @param string $controller
* @param string $method
* @return mixed
*/
public function dispatch(Route $route, Request $request, $controller, $method)
{
$instance = $this->makeController($controller);
$this->assignAfter($instance, $route, $request, $method);
//
$response = $this->before($instance, $route, $request, $method);
if (is_null($response)) {
$response = $this->call($instance, $route, $method);
}
return $response;
}
/**
* Make a controller instance via the IoC container.
*
* @param string $controller
* @return mixed
*/
protected function makeController($controller)
{
Controller::setFilterer($this->filterer);
return $this->container->make($controller);
}
/**
* Call the given controller instance method.
* @return bool
*/
protected function customDispatcherIsBound()
{
return $this->container->bound('framework.route.dispatcher');
}
/**
* Send the request and route to a custom dispatcher for handling.
*
* @param \Nova\Http\Request $request
* @return mixed
*/
protected function runWithCustomDispatcher(Request $request)
{
list($class, $method) = explode('@', $this->action['uses']);
$dispatcher = $this->container->make('framework.route.dispatcher');
return $dispatcher->dispatch($this, $request, $class, $method);
}
/**
* Checks if a Request matches the Route pattern.
*
* @param \Http\Request $request The dispatched Request instance
* @param bool $includingMethod Wheter or not is matched the HTTP Method
* @return bool Match status
*/
public function matches(Request $request, $includingMethod = true)
{
$this->compileRoute();
foreach ($this->getValidators() as $validator) {
if (! $includingMethod && ($validator instanceof MethodValidator)) continue;
if (! $validator->matches($this, $request)) return false;
}
return true;
}
}
/**
* Run the route action and return the response.
*
* @param \Nova\Http\Request $request
* @return mixed
*/
public function run(Request $request)
{
$this->container = $this->container ?: new Container();
try {
if (! is_string($this->action['uses'])) {
return $this->runCallable($request);
}
if ($this->customDispatcherIsBound()) {
return $this->runWithCustomDispatcher($request);
}
return $this->runController($request);
}
catch (HttpResponseException $e) {
return $e->getResponse();
}
}
/**
* Run the route action and return the response.
*
* @param \Nova\Http\Request $request
* @return mixed
*/
protected function runCallable(Request $request)
{
$callable = $this->action['uses'];
$parameters = $this->resolveMethodDependencies(
*/
public function dispatchToRoute(Request $request)
{
// Execute the Routes matching.
$route = $this->findRoute($request);
$request->setRouteResolver(function() use ($route)
{
return $route;
});
$this->events->fire('router.matched', array($route, $request));
// Once we have successfully matched the incoming request to a given route we
// can call the before filters on that route. This works similar to global
// filters in that if a response is returned we will not call the route.
$response = $this->callRouteBefore($route, $request);
if (is_null($response)) {
$response = $route->run($request);
}
// Prepare the Reesponse.
$response = $this->prepareResponse($request, $response);
// After we have a prepared response from the route or filter we will call to
// the "after" filters to do any last minute processing on this request or
// response object before the response is returned back to the consumer.
$this->callRouteAfter($route, $request, $response);
return $response;
}
/**
* Dispatch the request to a asset file and return the response.
*
* @param \Nova\Http\Request $request
* @return mixed
*/
public function dispatchToFile(Request $request)
/**
* Dispatch route
* @return bool
*/
public function dispatch(Request $request)
{
$this->currentRequest = $request;
// Asset Files Dispatching.
$response = $this->dispatchToFile($request);
if (! is_null($response)) return $response;
// If no response was returned from the before filter, we will call the proper
// route instance to get the response. If no route is found a response will
// still get returned based on why no routes were found for this request.
$response = $this->callFilter('before', $request);
if (is_null($response)) {
$response = $this->dispatchToRoute($request);
}
$response = $this->prepareResponse($request, $response);
// Once this route has run and the response has been prepared, we will run the
// after filter to do any last work on the response or for this application
// before we will return the response back to the consuming code for use.
$this->callFilter('after', $request, $response);
return $response;
}
/**
* Dispatch the request to a route and return the response.
*
* @param \Nova\Http\Request $request
* @return mixed
*/
public function dispatchToRoute(Request $request)
{
/**
* Handle the given request and get the response.
*
* @param \Nova\Http\Request $request
* @return \Symfony\Component\HttpFoundation\Response
*/
public function dispatch(Request $request)
{
if ($this->isDownForMaintenance()) {
$response = $this['events']->until('nova.app.down');
if (! is_null($response)) return $this->prepareResponse($response, $request);
}
if ($this->runningUnitTests() && ! $this['session']->isStarted()) {
$this['session']->start();
}
return $this['router']->dispatch($this->prepareRequest($request));
}
/**
* Call the "finish" and "shutdown" callbacks assigned to the application.
*
* @param \Symfony\Component\HttpFoundation\Request $request
* @param \Symfony\Component\HttpFoundation\Response $response
* @return void
*/
public function terminate(SymfonyRequest $request, SymfonyResponse $response)
{
$this->callFinishCallbacks($request, $response);
$this->shutdown();
}
/**
* Refresh the bound request instance in the container.
*
* @param \Nova\Http\Request $request
*
* Provides compatibility with BrowserKit functional testing.
*
* @implements HttpKernelInterface::handle
*
* @param \Symfony\Component\HttpFoundation\Request $request
* @param int $type
* @param bool $catch
* @return \Symfony\Component\HttpFoundation\Response
*
* @throws \Exception
*/
public function handle(SymfonyRequest $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = true)
{
try {
$this->refreshRequest($request = Request::createFromBase($request));
$this->boot();
return $this->dispatch($request);
}
catch (\Exception $e) {
if (! $catch || $this->runningUnitTests()) throw $e;
return $this['exception']->handleException($e);
}
catch (\Throwable $e) {
if (! $catch || $this->runningUnitTests()) throw $e;
return $this['exception']->handleException($e);
}
}
/**
* Handle the given request and get the response.
*
* @param \Nova\Http\Request $request
* @return \Symfony\Component\HttpFoundation\Response
*/
public function dispatch(Request $request)
public function __construct(HttpKernelInterface $app, $debug)
{
$this->app = $app;
$this->debug = $debug;
}
/**
* Handle the given request and get the response.
*
* @implements HttpKernelInterface::handle
*
* @param \Symfony\Component\HttpFoundation\Request $request
* @param int $type
* @param bool $catch
* @return \Symfony\Component\HttpFoundation\Response
*/
public function handle(SymfonyRequest $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = true)
{
$response = $this->app->handle($request, $type, $catch);
if (! $this->isHtmlResponse($response)) return $response;
return $this->processResponse($response);
}
/**
* Minify the Response instance Content.
*
* @param \Symfony\Component\HttpFoundation\Response $response
* @return void
*/
protected function processResponse(SymfonyResponse $response)
{
if ($this->debug) {
// Insert the QuickProfiler Widget in the Response's Content.
$content = str_replace(
array(
'<!-- DO NOT DELETE! - Forensics Profiler -->',
'<!-- DO NOT DELETE! - Profiler -->',
*
* @param \Symfony\Component\HttpFoundation\Request $request
* @param int $type
* @param bool $catch
* @return \Symfony\Component\HttpFoundation\Response
*/
public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = true)
{
$this->checkRequestForArraySessions($request);
// If a session driver has been configured, we will need to start the session here
// so that the data is ready for an application. Note that the Nova sessions
// do not make use of PHP "native" sessions in any way since they are crappy.
if ($this->sessionConfigured()) {
$session = $this->startSession($request);
$request->setSession($session);
}
$response = $this->app->handle($request, $type, $catch);
// Again, if the session has been configured we will need to close out the session
// so that the attributes may be persisted to some storage medium. We will also
// add the session identifier cookie to the application response headers now.
if ($this->sessionConfigured()) {
$this->closeSession($session);
$this->addCookieToResponse($response, $session);
}
return $response;
}
/**
* Check the request and reject callback for array sessions.
*
* @param \Symfony\Component\HttpFoundation\Request $request
* @return void
*/
public function checkRequestForArraySessions(Request $request)
*/
public function __construct(HttpKernelInterface $app, CookieJar $cookies)
{
$this->app = $app;
$this->cookies = $cookies;
}
/**
* Handle the given request and get the response.
*
* @implements HttpKernelInterface::handle
*
* @param \Symfony\Component\HttpFoundation\Request $request
* @param int $type
* @param bool $catch
* @return \Symfony\Component\HttpFoundation\Response
*/
public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = true)
{
$response = $this->app->handle($request, $type, $catch);
foreach ($this->cookies->getQueuedCookies() as $cookie) {
$response->headers->setCookie($cookie);
}
return $response;
}
}
*/
public function __construct(HttpKernelInterface $app, Encrypter $encrypter)
{
$this->app = $app;
$this->encrypter = $encrypter;
}
/**
* Handle the given request and get the response.
*
* @implements HttpKernelInterface::handle
*
* @param \Symfony\Component\HttpFoundation\Request $request
* @param int $type
* @param bool $catch
* @return \Symfony\Component\HttpFoundation\Response
*/
public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = true)
{
$response = $this->app->handle($this->decrypt($request), $type, $catch);
return $this->encrypt($response);
}
/**
* Decrypt the cookies on the request.
*
* @param \Symfony\Component\HttpFoundation\Request $request
* @return \Symfony\Component\HttpFoundation\Request
*/
protected function decrypt(Request $request)
{
foreach ($request->cookies as $key => $cookie) {
if($key == 'PHPSESSID') {
// Leave alone the PHPSESSID.
continue;
}
try
{
use Symfony\Component\HttpKernel\HttpKernelInterface;
use Symfony\Component\HttpKernel\TerminableInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
class StackedHttpKernel implements HttpKernelInterface, TerminableInterface
{
private $app;
private $middlewares = array();
public function __construct(HttpKernelInterface $app, array $middlewares)
{
$this->app = $app;
$this->middlewares = $middlewares;
}
public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = true)
{
return $this->app->handle($request, $type, $catch);
}
public function terminate(Request $request, Response $response)
{
$prevKernel = null;
foreach ($this->middlewares as $kernel) {
// if prev kernel was terminable we can assume this middleware has already been called
if (!$prevKernel instanceof TerminableInterface && $kernel instanceof TerminableInterface) {
$kernel->terminate($request, $response);
}
$prevKernel = $kernel;
}
}
}
* @return void
*/
public function booted($callback)
{
$this->bootedCallbacks[] = $callback;
if ($this->isBooted()) $this->fireAppCallbacks(array($callback));
}
/**
* Run the application and send the response.
*
* @param \Symfony\Component\HttpFoundation\Request $request
* @return void
*/
public function run(SymfonyRequest $request = null)
{
$request = $request ?: $this['request'];
$response = with($stack = $this->getStackedClient())->handle($request);
$response->send();
$stack->terminate($request, $response);
}
/**
* Get the stacked HTTP kernel for the application.
*
* @return \Symfony\Component\HttpKernel\HttpKernelInterface
*/
protected function getStackedClient()
{
$sessionReject = $this->bound('session.reject') ? $this['session.reject'] : null;
$client = (new Builder)
->push('Nova\Cookie\Guard', $this['encrypter'])
->push('Nova\Cookie\Queue', $this['cookie'])
->push('Nova\Session\Middleware', $this['session'], $sessionReject);
define('PUBLICDIR', realpath(__DIR__) .DS);
//--------------------------------------------------------------------------
// Load the Composer Autoloader
//--------------------------------------------------------------------------
require ROOTDIR .'vendor' .DS .'autoload.php';
//--------------------------------------------------------------------------
// Bootstrap the Framework and get the Application instance
//--------------------------------------------------------------------------
$app = require_once APPDIR .'Boot' .DS .'Start.php';
//--------------------------------------------------------------------------
// Run the Application
//--------------------------------------------------------------------------
$app->run();