Inheritance: implements Psr\Log\LoggerInterface
 public function call()
 {
     $app = $this->app;
     $storage_path_or_clockwork = $this->storage_path_or_clockwork;
     $this->app->container->singleton('clockwork', function () use($app, $storage_path_or_clockwork) {
         if ($storage_path_or_clockwork instanceof Clockwork) {
             return $storage_path_or_clockwork;
         }
         $clockwork = new Clockwork();
         $clockwork->addDataSource(new PhpDataSource())->addDataSource(new SlimDataSource($app))->setStorage(new FileStorage($storage_path_or_clockwork));
         return $clockwork;
     });
     $original_log_writer = $this->app->getLog()->getWriter();
     $clockwork_log_writer = new ClockworkLogWriter($this->app->clockwork, $original_log_writer);
     $this->app->getLog()->setWriter($clockwork_log_writer);
     if ($this->app->config('debug') && preg_match('#/__clockwork(/(?<id>[0-9\\.]+))?#', $this->app->request()->getPathInfo(), $matches)) {
         return $this->retrieveRequest($matches['id']);
     }
     try {
         $this->next->call();
         $this->logRequest();
     } catch (Exception $e) {
         $this->logRequest();
         throw $e;
     }
 }
 public function register()
 {
     $this->app->singleton('clockwork.laravel', function ($app) {
         return new LaravelDataSource($app);
     });
     $this->app->singleton('clockwork.swift', function ($app) {
         return new SwiftDataSource($app['mailer']->getSwiftMailer());
     });
     $this->app->singleton('clockwork', function ($app) {
         $clockwork = new Clockwork();
         $clockwork->addDataSource(new PhpDataSource())->addDataSource($app['clockwork.laravel'])->addDataSource($app['clockwork.swift']);
         $filter = $app['config']->get('clockwork::config.filter', array());
         if ($app['config']->get('database.default') && !in_array('databaseQueries', $filter)) {
             $clockwork->addDataSource(new EloquentDataSource($app['db']->connection()));
         }
         $storage = new FileStorage($app['path.storage'] . '/clockwork');
         $storage->filter = $filter;
         $clockwork->setStorage($storage);
         return $clockwork;
     });
     $this->registerCommands();
     $app = $this->app;
     $service = $this;
     $this->app->after(function ($request, $response) use($app, $service) {
         if (!$service->isCollectingData()) {
             return;
             // Collecting data is disabled, return immediately
         }
         // don't collect data for configured URIs
         $request_uri = $app['request']->getRequestUri();
         $filter_uris = $app['config']->get('clockwork::config.filter_uris', array());
         $filter_uris[] = '/__clockwork/[0-9\\.]+';
         // don't collect data for Clockwork requests
         foreach ($filter_uris as $uri) {
             $regexp = '#' . str_replace('#', '\\#', $uri) . '#';
             if (preg_match($regexp, $request_uri)) {
                 return;
             }
         }
         $app['clockwork.laravel']->setResponse($response);
         $app['clockwork']->resolveRequest();
         $app['clockwork']->storeRequest();
         if (!$service->isEnabled()) {
             return;
             // Clockwork is disabled, don't set the headers
         }
         $response->headers->set('X-Clockwork-Id', $app['clockwork']->getRequest()->id, true);
         $response->headers->set('X-Clockwork-Version', Clockwork::VERSION, true);
         if ($app['request']->getBasePath()) {
             $response->headers->set('X-Clockwork-Path', $app['request']->getBasePath() . '/__clockwork/', true);
         }
         $extra_headers = $app['config']->get('clockwork::config.headers');
         if ($extra_headers && is_array($extra_headers)) {
             foreach ($extra_headers as $header_name => $header_value) {
                 $response->headers->set('X-Clockwork-Header-' . $header_name, $header_value);
             }
         }
     });
 }
 /**
  * Filter executed AFTER a request
  *
  * @param SS_HTTPRequest $request   Request container object
  * @param SS_HTTPResponse $response Response output object
  * @param DataModel $model          Current DataModel
  * @return boolean Whether to continue processing other filters. Null or true will continue processing (optional)
  */
 public function postRequest(SS_HTTPRequest $request, SS_HTTPResponse $response, DataModel $model)
 {
     if (isset($this->clockwork)) {
         $response->addHeader("X-Clockwork-Id", $this->clockwork->getRequest()->id);
         $response->addHeader("X-Clockwork-Version", Clockwork::VERSION);
         $response->addHeader('X-Clockwork-Path', Director::baseURL() . '__clockwork/');
         $this->clockwork->resolveRequest();
         $this->clockwork->storeRequest();
     }
 }
 public function register()
 {
     if ($this->isLegacyLaravel() || $this->isOldLaravel()) {
         $this->package('itsgoingd/clockwork', 'clockwork', __DIR__);
     } else {
         $this->publishes(array(__DIR__ . '/config/clockwork.php' => config_path('clockwork.php')));
     }
     $legacy = $this->isLegacyLaravel() || $this->isOldLaravel();
     $this->app->singleton('clockwork.support', function ($app) use($legacy) {
         return new ClockworkSupport($app, $legacy);
     });
     $this->app->singleton('clockwork.laravel', function ($app) {
         return new LaravelDataSource($app);
     });
     $this->app->singleton('clockwork.swift', function ($app) {
         return new SwiftDataSource($app['mailer']->getSwiftMailer());
     });
     $this->app->singleton('clockwork.eloquent', function ($app) {
         return new EloquentDataSource($app['db'], $app['events']);
     });
     foreach ($this->app['clockwork.support']->getAdditionalDataSources() as $name => $callable) {
         $this->app->singleton($name, $callable);
     }
     $this->app->singleton('clockwork', function ($app) {
         $clockwork = new Clockwork();
         $clockwork->addDataSource(new PhpDataSource())->addDataSource($app['clockwork.laravel'])->addDataSource($app['clockwork.swift']);
         if ($app['clockwork.support']->isCollectingDatabaseQueries()) {
             $clockwork->addDataSource($app['clockwork.eloquent']);
         }
         foreach ($app['clockwork.support']->getAdditionalDataSources() as $name => $callable) {
             $clockwork->addDataSource($app[$name]);
         }
         $clockwork->setStorage($app['clockwork.support']->getStorage());
         return $clockwork;
     });
     $this->app['clockwork.laravel']->listenToEvents();
     // set up aliases for all Clockwork parts so they can be resolved by the IoC container
     $this->app->alias('clockwork.support', 'Clockwork\\Support\\Laravel\\ClockworkSupport');
     $this->app->alias('clockwork.laravel', 'Clockwork\\DataSource\\LaravelDataSource');
     $this->app->alias('clockwork.swift', 'Clockwork\\DataSource\\SwiftDataSource');
     $this->app->alias('clockwork.eloquent', 'Clockwork\\DataSource\\EloquentDataSource');
     $this->app->alias('clockwork', 'Clockwork\\Clockwork');
     $this->registerCommands();
     if ($this->isLegacyLaravel()) {
         $this->app->middleware('Clockwork\\Support\\Laravel\\ClockworkLegacyMiddleware', array($this->app));
     } else {
         if ($this->isOldLaravel()) {
             $app = $this->app;
             $this->app['router']->after(function ($request, $response) use($app) {
                 return $app['clockwork.support']->process($request, $response);
             });
         }
     }
 }
 public function register()
 {
     $this->app->singleton('clockwork.support', function ($app) {
         return new ClockworkSupport($app);
     });
     $this->app->singleton('clockwork.lumen', function ($app) {
         return new LumenDataSource($app);
     });
     $this->app->singleton('clockwork.swift', function ($app) {
         return new SwiftDataSource($app['mailer']->getSwiftMailer());
     });
     $this->app->singleton('clockwork.eloquent', function ($app) {
         return new EloquentDataSource($app['db'], $app['events']);
     });
     foreach ($this->app['clockwork.support']->getAdditionalDataSources() as $name => $callable) {
         $this->app->singleton($name, $callable);
     }
     $this->app->singleton('clockwork', function ($app) {
         $clockwork = new Clockwork();
         $clockwork->addDataSource(new PhpDataSource())->addDataSource($app['clockwork.lumen']);
         if ($app['clockwork.support']->isCollectingDatabaseQueries()) {
             $clockwork->addDataSource($app['clockwork.eloquent']);
         }
         if ($app['clockwork.support']->isCollectingEmails()) {
             $clockwork->addDataSource($app['clockwork.swift']);
         }
         foreach ($app['clockwork.support']->getAdditionalDataSources() as $name => $callable) {
             $clockwork->addDataSource($app[$name]);
         }
         $clockwork->setStorage($app['clockwork.support']->getStorage());
         return $clockwork;
     });
     $this->app['clockwork.lumen']->listenToEvents();
     // set up aliases for all Clockwork parts so they can be resolved by the IoC container
     $this->app->alias('clockwork.support', 'Clockwork\\Support\\Lumen\\ClockworkSupport');
     $this->app->alias('clockwork.lumen', 'Clockwork\\DataSource\\LumenDataSource');
     $this->app->alias('clockwork.swift', 'Clockwork\\DataSource\\SwiftDataSource');
     $this->app->alias('clockwork.eloquent', 'Clockwork\\DataSource\\EloquentDataSource');
     $this->app->alias('clockwork', 'Clockwork\\Clockwork');
     $this->registerCommands();
     if ($this->app['clockwork.support']->getConfig('register_helpers', true)) {
         require __DIR__ . '/helpers.php';
     }
 }
 public function register()
 {
     $this->app->singleton('clockwork.support', function ($app) {
         return new ClockworkSupport($app);
     });
     $this->app->singleton('clockwork.lumen', function ($app) {
         return new LumenDataSource($app);
     });
     $this->app->singleton('clockwork.eloquent', function ($app) {
         return new EloquentDataSource($app['db'], $app['events']);
     });
     foreach ($this->app['clockwork.support']->getAdditionalDataSources() as $name => $callable) {
         $this->app->singleton($name, $callable);
     }
     $this->app->singleton('clockwork', function ($app) {
         $clockwork = new Clockwork();
         $clockwork->addDataSource(new PhpDataSource())->addDataSource(new MonologDataSource($app['log']))->addDataSource($app['clockwork.lumen']);
         $extraDataProviders = $app['config']->get('profiler.extraDataProviders', []);
         foreach ($extraDataProviders as $extraDataProvider) {
             $clockwork->addDataSource(new $extraDataProvider());
         }
         if ($app['clockwork.support']->isCollectingDatabaseQueries()) {
             $clockwork->addDataSource($app['clockwork.eloquent']);
         }
         foreach ($app['clockwork.support']->getAdditionalDataSources() as $name => $callable) {
             $clockwork->addDataSource($app[$name]);
         }
         $clockwork->setStorage($app['clockwork.support']->getStorage());
         return $clockwork;
     });
     $this->app['clockwork.lumen']->listenToEvents();
     // set up aliases for all Clockwork parts so they can be resolved by the IoC container
     $this->app->alias('clockwork.support', 'Clockwork\\Support\\Lumen\\ClockworkSupport');
     $this->app->alias('clockwork.lumen', 'Clockwork\\DataSource\\LumenDataSource');
     $this->app->alias('clockwork.eloquent', 'Clockwork\\DataSource\\EloquentDataSource');
     $this->app->alias('clockwork', 'Clockwork\\Clockwork');
     $this->registerCommands();
 }
 /**
  * 
  *
  * @static 
  */
 public static function endEvent($name)
 {
     return \Clockwork\Clockwork::endEvent($name);
 }
Exemple #8
0
 /**
  * @param EntityManagerInterface $em
  * @param Configuration          $configuration
  */
 public function register(EntityManagerInterface $em, Configuration $configuration)
 {
     $debugStack = new DebugStack();
     $configuration->setSQLLogger($debugStack);
     $this->clockwork->addDataSource(new DoctrineDataSource($debugStack, $em->getConnection()->getDriver()->getName()));
 }
 /**
  * @return Clockwork
  */
 public function onClockworkService()
 {
     $clockwork = new Clockwork();
     $clockwork->setStorage(new FileStorage($this->getClockworkLogPath()));
     return $clockwork;
 }