// what we should do when the model is not found. This just gives these
// developer a little greater flexibility to decide what will happen.
if ($callback instanceof Closure)
{
return call_user_func($callback);
}
throw new NotFoundHttpException;
});
}
* @param string $key
* @param mixed $value
* @param \Illuminate\Routing\Route $route
* @return mixed
*/
public function performBinding($key, $value, $route)
{
return call_user_func($this->binders[$key], $value, $route);
}
$value = $this->parameters[$key];
// If the parameter has a binder, we will call the binder to resolve the real
// value for the parameters. The binders could make a database call to get
// a User object for example or may transform the input in some fashion.
if ($this->router->hasBinder($key))
{
return $this->router->performBinding($key, $value, $this);
}
// To get the parameter array, we need to spin the names of the variables on
// the compiled route and match them to the parameters that we got when a
// route is matched by the router, as routes instances don't have them.
$parameters = array();
foreach ($variables as $variable)
{
$parameters[$variable] = $this->resolveParameter($variable);
}
*
* @param string $name
* @param mixed $default
* @return string
*/
public function getParameter($name, $default = null)
{
return array_get($this->getParameters(), $name, $default);
}
if (!Cache::has($key)) {
Cache::put($key,$response->getContent(),$this->getTtlVillas());
}
}
public function fetchOffer(Route $route,Request $request)
{
$offer_id = $route->getParameter('offer')->id;
$key = $this->makeOfferKey($offer_id);
// Next we will parse the filter name to extract out any parameters and adding
// any parameters specified in a filter name to the end of the lists of our
// parameters, since the ones at the beginning are typically very static.
list($name, $params) = $this->parseFilter($name, $params);
if ( ! is_null($callable = $this->router->getFilter($name)))
{
return call_user_func_array($callable, $params);
}
}
$response = null;
// Once we have each middlewares, we will simply iterate through them and call
// each one of them with the request. We will set the response variable to
// whatever it may return so that it may override the request processes.
foreach ($before as $filter)
{
$response = $this->callFilter($filter, $request);
if ( ! is_null($response)) return $response;
public function run(Request $request)
{
$this->parsedParameters = null;
// We will only call the router callable if no "before" middlewares returned
// a response. If they do, we will consider that the response to requests
// so that the request "lifecycle" will be easily halted for filtering.
$response = $this->callBeforeFilters($request);
if ( ! isset($response))
// Once we have the route, we can just run it to get the responses, which will
// always be instances of the Response class. Once we have the responses we
// will execute the global "after" middlewares to finish off the request.
else
{
$this->currentRoute = $route = $this->findRoute($request);
$response = $route->run($request);
}
if ($this->isDownForMaintenance())
{
$response = $this['events']->until('illuminate.app.down');
if ( ! is_null($response)) return $this->prepareResponse($response, $request);
}
return $this['router']->dispatch($this->prepareRequest($request));
}
/**
* Handles the given request and delivers the response.
*
* @return void
*/
public function run()
{
$response = $this->dispatch($this['request']);
$this['router']->callCloseFilter($this['request'], $response);
| 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 applications we have created for them.
|
*/
$app->run();
/*