setStorage() public method

Set a custom storage object
public setStorage ( Clockwork\Storage\StorageInterface $storage )
$storage Clockwork\Storage\StorageInterface
 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);
             }
         }
     });
 }
 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);
             });
         }
     }
 }
 /**
  * Filter executed before a request processes
  *
  * @param SS_HTTPRequest $request Request container object
  * @param Session $session        Request session
  * @param DataModel $model        Current DataModel
  * @return boolean Whether to continue processing other filters. Null or true will continue processing (optional)
  */
 public function preRequest(SS_HTTPRequest $request, Session $session, DataModel $model)
 {
     if (Director::isDev() && class_exists('Clockwork\\Clockwork')) {
         $this->clockwork = new Clockwork();
         if (!DB::get_conn()) {
             global $databaseConfig;
             if ($databaseConfig) {
                 DB::connect($databaseConfig);
             }
         }
         // Wrap the current database adapter in a proxy object so we can log queries
         DB::set_conn(new DatabaseProxy(DB::get_conn()));
         $this->clockwork->addDataSource(new SilverstripeDataSource());
         // Attach a default datasource that comes with
         // the Clockwork library (grabs session info, etc)
         $this->clockwork->addDataSource(new PhpDataSource());
         // Give it a place to store data
         $this->clockwork->setStorage(new FileStorage(TEMP_FOLDER . '/clockwork'));
     }
 }
 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();
 }
Beispiel #6
0
 /**
  * Set a custom storage object
  *
  * @static 
  */
 public static function setStorage($storage)
 {
     return \Clockwork\Clockwork::setStorage($storage);
 }
 /**
  * @return Clockwork
  */
 public function onClockworkService()
 {
     $clockwork = new Clockwork();
     $clockwork->setStorage(new FileStorage($this->getClockworkLogPath()));
     return $clockwork;
 }