public function registerLastPerformance() { $app = \Raptor\Raptor::getInstance(); $time = round($app->getTimer()->getExecutionTime(), 2); $cache = new \Raptor\Cache\Cache('performance'); if (!$cache->hasCache()) { $performance = new \Raptor\Util\ItemList(); } else { $performance = $cache->getData(); } if ($performance->size() < 20) { $performance->add($time); } else { $performance->shift(); $performance->add($time); } $cache->setData($performance); $cache->save(); }
private function read() { if (!$this->cacheautoinstaller->isDirty()) { $this->autoinstaller = $this->cacheautoinstaller->getData(); } if ($this->cache->isDirty()) { $this->monitor->execute(); $this->checkForGhosts(); $app = Location::get(Location::APP); $this->options['options'] = \Raptor\Yaml\Yaml::parse($app . '/conf/options.yml'); $this->options['bundles'] = \Raptor\Yaml\Yaml::parse($app . '/conf/bundles.yml'); /** * Add the system routes and the bundles * check fot enviroment * if(development) */ $this->options['bundles'] = array_merge(\Raptor\Yaml\Yaml::parse(__DIR__ . '/../Component/bundles.yml'), $this->options['bundles']); /** * Must call this before the Reader */ // \Raptor\Raptor::getInstance()->getAppAspectKernel()->resetContainer(); foreach ($this->options['bundles'] as $bundle) { $cmp_str = $bundle; $cmp = new $cmp_str(); call_user_func_array(array($cmp, 'init'), array()); $container = \Raptor\Raptor::getInstance()->getAppAspectKernel()->getContainer(); $trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 2); $refClass = new \ReflectionObject($cmp); $container->addResource($trace[1]['file']); $container->addResource($refClass->getFileName()); } $this->reader->setBundles($this->options['bundles']); $this->reader->load(); $this->options['routes'] = $this->reader->getDefinitions(); $this->options['location'] = $this->reader->getLocation(); $this->options['specifications'] = $this->reader->getSpecifications(); $this->options['description'] = $this->reader->getDescriptions(); $this->cache->setData($this->options); $this->cache->save(); /** * Save the API to access in the main Raptor class */ $api = new \Raptor\Cache\Cache('api'); $api->setData($this->reader->getApi()); $api->save(); /** * Save the Auto Install Cache to know the trace of installed bundled */ $this->cacheautoinstaller->setData($this->autoinstaller); $this->cacheautoinstaller->save(); } else { $this->options = $this->cache->getData(); foreach ($this->options['bundles'] as $bundle) { $cmp_str = $bundle; $cmp = new $cmp_str(); call_user_func_array(array($cmp, 'init'), array()); $container = \Raptor\Raptor::getInstance()->getAppAspectKernel()->getContainer(); $trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 2); $refClass = new \ReflectionObject($cmp); $container->addResource($trace[1]['file']); $container->addResource($refClass->getFileName()); } } }