{
$this['events']->listen('illuminate.app.down', $callback);
}
/**
* Throw an HttpException with the given data.
*
* @param int $code
* @param string $message
* @param array $headers
* @return void
*
* @throws \Symfony\Component\HttpKernel\Exception\HttpException
* @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException
*/
public function abort($code, $message = '', array $headers = array())
{
if ($code == 404)
{
throw new NotFoundHttpException($message);
}
throw new HttpException($code, $message, null, $headers);
}
/**
* Register a 404 error handler.
*
* @param \Closure $callback
* @return void
*/
public function missing(Closure $callback)
{
$this->error(function(NotFoundHttpException $e) use ($callback)
{
return call_user_func($callback, $e);
});
}
/**
}
/**
* Handle dynamic, static calls to the object.
*
* @param string $method
* @param array $args
* @return mixed
*/
public static function __callStatic($method, $args)
{
$instance = static::getFacadeRoot();
switch (count($args))
{
case 0:
return $instance->$method();
case 1:
return $instance->$method($args[0]);
case 2:
return $instance->$method($args[0], $args[1]);
case 3:
return $instance->$method($args[0], $args[1], $args[2]);
case 4:
return $instance->$method($args[0], $args[1], $args[2], $args[3]);
default:
return call_user_func_array(array($instance, $method), $args);
}
}
}
if ($page->hasOffer()) {
$_SESSION['offer'] = new SessionAttachedOffer($page->getAttachedOffer(),$page->isOfferApplied());
setcookie('offer',base64_encode(serialize($_SESSION['offer'])),null,'/','boxgroove.com');
}
if (null !== $page->getOrganization()) {
$_SESSION['insertOrg'] = $page->getOrganization()->getId();
setcookie('insertOrg',$page->getOrganization()->getId(),time()+(180*24*60*60),'/','boxgroove.com');
}
$this->layout->content = \View::make($template)->with([
'content'=>$content,
'scripts'=>$page->getScripts(),
'styles'=>$page->getStyles(),
'title'=>$page->getTitle()
]);
}else{
\App::abort(404);
}
}
}
$tower = View::make('layouts.modules.tower_ad')->render();
View::share('bannerAd',$banner);
View::share('towerAd',$tower);
}
final public function setCurrentAction($currentAction)
{
\View::share('currentAction',$currentAction);
}
final public function callAction($method, $parameters)
{
$currentAction = \Route::current()->getAction()['as'];
$this->setCurrentAction($currentAction);
$this->setupLayout();
$this->setupNavigation();
$this->setupAds();
$response = call_user_func_array([$this, $method], $parameters);
// If no response is returned from the controller action and a layout is being
// used we will assume we want to just return the layout view as any nested
// views were probably bound on this view during this controller actions.
if (is_null($response) && ! is_null($this->layout))
{
$response = $this->layout;
}
return $response;
}
}
protected function makeController($controller)
{
Controller::setFilterer($this->filterer);
return $this->container->make($controller);
}
/**
* Call the given controller instance method.
*
* @param \Illuminate\Routing\Controller $instance
* @param \Illuminate\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 \Illuminate\Routing\Controller $instance
* @param \Illuminate\Routing\Route $route
* @param \Illuminate\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))
{
// Here we will just check if the filter applies. If it does we will call the filter
// and return the responses if it isn't null. If it is null, we will keep hitting
// them until we get a response or are finished iterating through this filters.
* @param string $method
* @return mixed
*/
public function dispatch(Route $route, Request $request, $controller, $method)
{
// First we will make an instance of this controller via the IoC container instance
// so that we can call the methods on it. We will also apply any "after" filters
// to the route so that they will be run by the routers after this processing.
$instance = $this->makeController($controller);
$this->assignAfter($instance, $route, $request, $method);
$response = $this->before($instance, $route, $request, $method);
// If no before filters returned a response we'll call the method on the controller
// to get the response to be returned to the router. We will then return it back
// out for processing by this router and the after filters can be called then.
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.
*/
protected function getClassClosure($controller)
{
// Here we'll get an instance of this controller dispatcher and hand it off to
// the Closure so it will be used to resolve the class instances out of our
// IoC container instance and call the appropriate methods on the class.
$d = $this->getControllerDispatcher();
return function() use ($d, $controller)
{
$route = $this->current();
$request = $this->getCurrentRequest();
// Now we can split the controller and method out of the action string so that we
// can call them appropriately on the class. This controller and method are in
// in the Class@method format and we need to explode them out then use them.
list($class, $method) = explode('@', $controller);
return $d->dispatch($route, $request, $class, $method);
};
}
/**
* Prepend the last group uses onto the use clause.
*
* @param string $uses
* @return string
*/
protected function prependGroupUses($uses)
{
$group = last($this->groupStack);
return isset($group['namespace']) ? $group['namespace'].'\\'.$uses : $uses;
}
/**
* Dispatch the request to the application.
*
* @param \Illuminate\Http\Request $request
{
$this->methods[] = 'HEAD';
}
if (isset($this->action['prefix']))
{
$this->prefix($this->action['prefix']);
}
}
/**
* Run the route action and return the response.
*
* @return mixed
*/
public function run()
{
$parameters = array_filter($this->parameters(), function($p) { return isset($p); });
return call_user_func_array($this->action['uses'], $parameters);
}
/**
* Determine if the route matches given request.
*
* @param \Illuminate\Http\Request $request
* @param bool $includingMethod
* @return bool
*/
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;
}
{
$this->methods[] = 'HEAD';
}
if (isset($this->action['prefix']))
{
$this->prefix($this->action['prefix']);
}
}
/**
* Run the route action and return the response.
*
* @return mixed
*/
public function run()
{
$parameters = array_filter($this->parameters(), function($p) { return isset($p); });
return call_user_func_array($this->action['uses'], $parameters);
}
/**
* Determine if the route matches given request.
*
* @param \Illuminate\Http\Request $request
* @param bool $includingMethod
* @return bool
*/
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;
}
/**
* Dispatch the request to a route and return the response.
*
* @param \Illuminate\Http\Request $request
* @return mixed
*/
public function dispatchToRoute(Request $request)
{
$route = $this->findRoute($request);
$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);
}
$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;
}
/**
* Find the route matching a given request.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Routing\Route
*/
protected function findRoute($request)
{
}
/**
* Dispatch the request to the application.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function dispatch(Request $request)
{
$this->currentRequest = $request;
// 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 \Illuminate\Http\Request $request
* @return mixed
*/
public function dispatchToRoute(Request $request)
{
* Handle the given request and get the response.
*
* @param \Illuminate\Http\Request $request
* @return \Symfony\Component\HttpFoundation\Response
*/
public function dispatch(Request $request)
{
if ($this->isDownForMaintenance())
{
$response = $this['events']->until('illuminate.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 \Illuminate\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);
}
}
/**
* Handle the given request and get the response.
*
* @param \Illuminate\Http\Request $request
* @return \Symfony\Component\HttpFoundation\Response
*/
public function dispatch(Request $request)
{
if ($this->isDownForMaintenance())
{
$response = $this['events']->until('illuminate.app.down');
* @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 Laravel 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 __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)
{
return $this->encrypt($this->app->handle($this->decrypt($request), $type, $catch));
}
/**
* 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 => $c)
{
try
{
$request->cookies->set($key, $this->decryptCookie($c));
}
catch (DecryptException $e)
{
$request->cookies->set($key, null);
}
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('Illuminate\Cookie\Guard', $this['encrypter'])
->push('Illuminate\Cookie\Queue', $this['cookie'])
->push('Illuminate\Session\Middleware', $this['session'], $sessionReject);
| will load up this application so that we can run it and send
| the responses back to the browser and delight these users.
|
*/
$app = require_once __DIR__.'/../bootstrap/start.php';
/*
|--------------------------------------------------------------------------
| Run The Application
|--------------------------------------------------------------------------
|
| Once we have the application, we can simply call the run method,
| which will execute the request and send the response back to
| the client's browser allowing them to enjoy the creative
| and wonderful application we have whipped up for them.
|
*/
$app->run();