public function __construct()
 {
     parent::__construct();
     \Cloudmanic\WarChest\Libraries\Start::laravel_init();
     $this->filter('before', $this->before_filter);
     // Guess the model.
     if (empty($this->model)) {
         $tmp = explode('_', get_called_class());
         $this->model = $tmp[2];
     }
 }
Beispiel #2
0
 /**
  * Execute the route action and return the response.
  *
  * Unlike the "call" method, none of the attached filters will be run.
  *
  * @return mixed
  */
 public function response()
 {
     // If the action is a string, it is pointing the route to a controller
     // action, and we can just call the action and return its response.
     // We'll just pass the action off to the Controller class.
     $delegate = $this->delegate();
     if (!is_null($delegate)) {
         return Controller::call($delegate, $this->parameters);
     }
     // If the route does not have a delegate, then it must be a Closure
     // instance or have a Closure in its action array, so we will try
     // to locate the Closure and call it directly.
     $handler = $this->handler();
     if (!is_null($handler)) {
         return call_user_func_array($handler, $this->parameters);
     }
 }
Beispiel #3
0
 /**
  * Call a given route and return the route's response.
  *
  * @return Response
  */
 public function call()
 {
     // Since "before" filters can halt the request cycle, we will return
     // any response from the before filters. Allowing filters to halt the
     // request cycle makes tasks like authorization convenient.
     //
     // The route is responsible for running the global filters, and any
     // filters defined on the route itself. Since all incoming requests
     // come through a route (either defined or ad-hoc), it makes sense
     // to let the route handle the global filters. If the route uses
     // a controller, the controller will only call its own filters.
     $before = array_merge(array('before'), $this->filters('before'));
     $response = Filter::run($before, array(), true);
     if (is_null($response) and !is_null($response = $this->response())) {
         if ($response instanceof Delegate) {
             $response = Controller::call($response->destination, $this->parameters);
         }
     }
     if (!$response instanceof Response) {
         $response = new Response($response);
     }
     // Stringify the response. We need to force the response to be
     // stringed before closing the session, since the developer may
     // be using the session within their views, so we cannot age
     // the session data until the view is rendered.
     $response->content = $response->render();
     $filters = array_merge($this->filters('after'), array('after'));
     Filter::run($filters, array($response));
     return $response;
 }
Beispiel #4
0
 |		{
 |			return 'Hello World!';
 |		});
 |
 | It's easy to allow URI wildcards using (:num) or (:any):
 |
 |		Route::put('hello/(:any)', function($name)
 |		{
 |			return "Welcome, $name.";
 |		});
 |
*/
use Laravel\Routing\Route;
use Laravel\Routing\Controller;
// Detect all controllers and register to route
Route::controller(Controller::detect());
/*
 |--------------------------------------------------------------------------
 | Application 404 & 500 Error Handlers
 |--------------------------------------------------------------------------
 |
 | To centralize and simplify 404 handling, Laravel uses an awesome event
 | system to retrieve the response. Feel free to modify this function to
 | your tastes and the needs of your application.
 |
 | Similarly, we use an event to handle the display of 500 level errors
 | within the application. These errors are fired when there is an
 | uncaught exception thrown in the application.
 |
*/
Event::listen('404', function () {
 public function response()
 {
     $delegate = $this->delegate();
     if (!is_null($delegate)) {
         return Controller::call($delegate, $this->parameters);
     }
     $handler = $this->handler();
     if (!is_null($handler)) {
         return call_user_func_array($handler, $this->parameters);
     }
 }