예제 #1
0
 public function testStorageGetsUniqueSafeIdentifier()
 {
     $storage1 = new Storage();
     $storage2 = new Storage();
     $this->assertNotEquals($storage1->getRequestId(), $storage2->getRequestId());
     $this->assertGreaterThan(10, strlen($storage1->getRequestId()));
     $this->assertGreaterThan(10, strlen($storage2->getRequestId()));
     $this->assertRegExp('/[a-zA-Z0-9]+/', $storage1->getRequestId());
     $this->assertRegExp('/[a-zA-Z0-9]+/', $storage2->getRequestId());
 }
예제 #2
0
 /**
  * Creates profiler container in the view.
  * Attaches all data collector classes listeners to appropriate elements of the system.
  * 
  * Saves all collected data for the next request to display.
  */
 protected function attachHandlers()
 {
     foreach ($this->dataCollectors as $dataCollector) {
         $this->eventsManager->attach($dataCollector->getListenerType(), $dataCollector);
     }
     $this->eventsManager->attach('view:beforeRender', function ($event, $view) {
         $this->di->get('assets')->addCss('assets/css/profiler.css')->addJs('assets/js/profiler.js');
         $view->setVar('profilerRequestId', $this->storage->getRequestId());
     });
     // Profiled request details writer
     $this->eventsManager->attach('view:afterRender', function () {
         if (static::$profilerModuleName === $this->di->getShared('dispatcher')->getModuleName()) {
             return;
         }
         $this->storage->store($this);
     });
 }