priority = $priority; $this->checksName = $checksName; $this->stepName = $stepName; parent::__construct(); AliceUtilLogger::WriteLog(_AE_LOG_DEBUG, __CLASS__." :: New instance"); } protected function _prepare() { $this->progress = 0; $this->setStep($this->stepName); $this->setState('prepared'); } protected function _run() { // Run in a loop until we run out of time, or breakflag is set $registry = AliceFactory::getConfiguration(); $timer = AliceFactory::getTimer(); // Let's check if I already have a stack coming from previous call $this->log = $registry->get('volatile.alice.logToAnalyze'); $this->checks = $registry->get('volatile.alice.'.$this->checksName.'.checks', array()); $this->totalChecks = $registry->get('volatile.alice.'.$this->checksName.'.totalChecks', 0); // No incoming stack, let's build it now if(!$this->checks) { $this->checks = AliceUtilScripting::getChecksStack($this->checksName); $this->totalChecks = count($this->checks); } while( ($timer->getTimeLeft() > 0) && (!$registry->get('volatile.breakflag', false)) && count($this->checks)) { if ($this->getState() == 'postrun') { AliceUtilLogger::WriteLog(_AE_LOG_DEBUG, __CLASS__." :: Already finished"); $this->setStep("-"); $this->setSubstep(""); break; } else { // Did I finished every check? if(!$this->checks) { return; } $error = ''; $solution = ''; $className = array_shift($this->checks); $check = new $className($this->log); $this->setSubstep($check->getName()); $this->progress = ($this->totalChecks - count($this->checks)) / $this->totalChecks; // Well, check, do your job! try { $check->check(); } catch(Exception $e) { // Mhm... log didn't passed the check. Let's save the error and the suggested solution $error = $e->getMessage(); $solution = $check->getSolution(); } $result = $check->getResult(); $feedback = $registry->get('volatile.alice.feedback', array()); $feedback[] = array( 'check' => $check->getName(), 'result' => $result, 'error' => $error, 'solution' => $solution ); $registry->set('volatile.alice.feedback', $feedback); unset($check); } } // Let's save everything $registry->set('volatile.alice.requirements.checks', $this->checks); $registry->set('volatile.alice.requirements.totalChecks', $this->totalChecks); $this->setState('postrun'); } protected function _finalize() { $this->setState('finished'); } public function getProgress() { return $this->progress; } public function getStepName() { return $this->stepName; } }