public function boot()
 {
     if ($this->isRunningWithFacades() && !class_exists('Clockwork')) {
         class_alias('Clockwork\\Facade\\Clockwork', 'Clockwork');
     }
     if (!$this->app['clockwork.support']->isCollectingData()) {
         return;
         // Don't bother registering event listeners as we are not collecting data
     }
     if ($this->app['clockwork.support']->isCollectingDatabaseQueries()) {
         $this->app['clockwork.eloquent']->listenToEvents();
     }
     if (!$this->app['clockwork.support']->isEnabled()) {
         return;
         // Clockwork is disabled, don't register the route
     }
     /*
     |--------------------------------------------------------------------------
     | Debug routes
     |--------------------------------------------------------------------------
     */
     if (env('APP_DEBUG', false)) {
         $this->app->group(['middleware' => 'cors'], function () {
             $this->app->get('/__clockwork/{id}', ['as' => 'profiler.native', 'uses' => \Clockwork\Http\Profiler::class . '@getData']);
             $this->app->get('api/__profiler/profiles/', ['as' => 'profiler.list', 'uses' => \Clockwork\Http\Profiler::class . '@index']);
             $this->app->get('api/__profiler/profiles/stats', ['as' => 'profiler.stats', 'uses' => \Clockwork\Http\Profiler::class . '@stats']);
             $this->app->get('api/__profiler/profiles/last', ['as' => 'profiler.last', 'uses' => \Clockwork\Http\Profiler::class . '@last']);
             $this->app->get('api/__profiler/profiles/{id}', ['as' => 'profiler.show', 'uses' => \Clockwork\Http\Profiler::class . '@show']);
         });
     }
     /*
     |--------------------------------------------------------------------------
     | Override env configuration
     |--------------------------------------------------------------------------
     |
     | Disable profiler for profiler request
     |
     */
     $pathInfo = \Illuminate\Support\Facades\Request::getPathInfo();
     if (strpos($pathInfo, 'api/__profiler') > 0) {
         putenv("CLOCKWORK_COLLECT_DATA_ALWAYS=false");
         putenv("CLOCKWORK_ENABLE=false");
     }
 }
Пример #2
0
 /**
  * Returns the path being requested relative to the executed script.
  *
  * The path info always starts with a /.
  *
  * Suppose this request is instantiated from /mysite on localhost:
  *
  *  * http://localhost/mysite              returns an empty string
  *  * http://localhost/mysite/about        returns '/about'
  *  * http://localhost/mysite/enco%20ded   returns '/enco%20ded'
  *  * http://localhost/mysite/about?var=1  returns '/about'
  *
  * @return string The raw path (i.e. not urldecoded)
  *
  * @api
  */
 public function getPathInfo()
 {
     return parent::getPathInfo();
 }
Пример #3
0
 /**
  * Build pagination link.
  *
  * @param  integer $total
  * @param  integer $offset
  * @param  integer $limit
  * @return string
  */
 private function buildPagination($total = 0, $offset = 0, $limit = 0)
 {
     $links = array();
     if ($total > 0) {
         $baseUrl = Request::getSchemeAndHttpHost() . Request::getPathInfo();
         // Create the first page link
         if ($offset > 0) {
             $param = array();
             $param['offset'] = 0;
             if (!empty($limit)) {
                 $param['limit'] = $limit;
             }
             $links[] = '<' . $baseUrl . '?' . http_build_query($param) . '>; rel="first"';
         }
         // Create the previous page link
         $prevOffset = $offset - $limit;
         if ($prevOffset > 0) {
             $param = array();
             $param['offset'] = $prevOffset;
             if (!empty($limit)) {
                 $param['limit'] = $limit;
             }
             $links[] = '<' . $baseUrl . '?' . http_build_query($param) . '>; rel="previous"';
         }
         // Create the next page link
         $nextOffset = $offset + $limit;
         if ($nextOffset < $total - $limit) {
             $param = array();
             $param['offset'] = $nextOffset;
             if (!empty($limit)) {
                 $param['limit'] = $limit;
             }
             $links[] = '<' . $baseUrl . '?' . http_build_query($param) . '>; rel="next"';
         }
         // Create the last page link
         if ($offset < $total - $limit) {
             $param = array();
             $param['offset'] = $total - $limit;
             if (!empty($limit)) {
                 $param['limit'] = $limit;
             }
             $links[] = '<' . $baseUrl . '?' . http_build_query($param) . '>; rel="last"';
         }
     }
     return implode(',', $links);
 }