Beispiel #1
0
 /**
  * Register a engine with the repository so that
  * builds can use it
  *
  * @param Xinc\Server\Engine\EngineInterface $engine
  * @param boolean $default
  *
  * @return boolean
  */
 public function registerEngine(EngineInterface $engine, $default = false)
 {
     $engineClass = get_class($engine);
     if (isset($this->engines[$engine->getName()]) || isset($this->engines[$engineClass])) {
         \Xinc\Core\Logger::getInstance()->error('cannot load engine ' . $engineClass . ' already registered');
         return false;
     }
     $this->engines[$engine->getName()] = $engine;
     $this->engines[$engineClass] = $engine;
     if ($default) {
         $this->defaultEngine = $engine;
     }
     return true;
 }
Beispiel #2
0
 private function generateProjects()
 {
     $projects = array();
     foreach ($this->projectConfigs as $key => $projectConfig) {
         $project = new \Xinc\Core\Models\Project();
         foreach ($projectConfig->attributes() as $name => $value) {
             $method = 'set' . ucfirst(strtolower($name));
             if (method_exists($project, $method)) {
                 $project->{$method}((string) $value);
             } else {
                 \Xinc\Core\Logger::getInstance()->error('Trying to set "' . $name . '" on Xinc Project "' . $project->getName() . '" failed. No such setter.');
             }
         }
         // TODO: I don't think this is the right place.
         $project->setConfig($projectConfig);
         if ($project->getEngineName() === '') {
             $project->setEngineName = $this->projectGroup->getEngineName();
         }
         $this->projectGroup->addProject($project);
         $project->setGroup($this->projectGroup);
     }
 }
Beispiel #3
0
 /**
  * Initialize the Plugins
  * TODO: Not yet done only Sunrise is registered as engine by hand.
  *
  * @return void
  * @TODO Needs work.
  */
 protected function initPlugins()
 {
     \Xinc\Core\Logger::getInstance()->info('Load Plugin Config');
     \Xinc\Core\Plugin\Repository::getInstance()->loadPluginConfig($this->options['working-dir']);
 }
Beispiel #4
0
 /**
  * sets the status of the project
  *
  * @see Xinc\Core\Project\Status
  * @param integer $status
  * @return void
  */
 public function setStatus($status)
 {
     // @TODO Nothing a model should do.
     \Xinc\Core\Logger::getInstance()->info('[project] ' . $this->getName() . ': Setting status to ' . $status);
     $this->status = $status;
 }
Beispiel #5
0
 public function parseProject($project)
 {
     try {
         $this->parseTasks($project, $project->getConfig());
     } catch (\Exception $e) {
         \Xinc\Core\Logger::getInstance()->error($e->getMessage());
         $project->setStatus(\Xinc\Core\Project\Status::MISCONFIGURED);
     }
 }
Beispiel #6
0
 /**
  * Add a projectfile to the xinc processing
  *
  * @param string $fileName
  *
  * @return void
  */
 private function addProjectFile($fileName)
 {
     \Xinc\Core\Logger::getInstance()->info('Loading Project-File: ' . $fileName);
     try {
         $config = new \Xinc\Core\Project\Config($fileName);
         $group = $config->getProjectGroup();
         foreach ($group->getProjects() as $project) {
             $engine = Engine\Repository::getInstance()->getEngine($project->getEngineName());
             $name = $engine->getName();
             \Xinc\Core\Logger::getInstance()->info('Add project to engine: ' . $name);
             $this->{$name}->addProject($project);
         }
     } catch (\Xinc\Core\Project\Config\Exception\FileNotFoundException $notFound) {
         \Xinc\Core\Logger::getInstance()->error('Project Config File ' . $fileName . ' cannot be found');
     } catch (\Xinc\Server\Engine\Exception\NotFoundException $engineNotFound) {
         \Xinc\Core\Logger::getInstance()->error('Project Config File references an unknown Engine: ' . $engineNotFound->getMessage());
     }
 }
Beispiel #7
0
 /**
  * Parses the tasks/subtasks of a project-xml
  *
  * @param SimpleXmlElement $element
  * @param Xinc $project
  */
 private function parseTasks($build, $element, $taskRegistry)
 {
     foreach ($element as $taskName => $task) {
         $taskObject = \Xinc\Core\Task\Registry::getInstance()->get($taskName);
         $taskObject->init(null);
         $taskObject->setXml($task);
         foreach ($task->attributes() as $name => $value) {
             $method = 'set' . ucfirst(strtolower($name));
             if (method_exists($taskObject, $method)) {
                 $taskObject->{$method}((string) $value, $build);
             } else {
                 \Xinc\Core\Logger::getInstance()->error('Trying to set "' . $name . '" on task "' . $taskName . '" failed. No such setter.');
             }
         }
         $this->parseTasks($build, $task, $taskObject);
         if (!$taskObject->validate()) {
             \Xinc\Core\Logger::getInstance()->error('Error validating config.xml for task: ' . $taskObject->getName());
             $project->setStatus(Xinc_Project_Status::MISCONFIGURED);
             return;
         }
     }
 }
Beispiel #8
0
 /**
  * Initialize the logger with path to file and verbosity
  *
  * @return void
  */
 public function initLogger()
 {
     $logger = \Xinc\Core\Logger::getInstance();
     $logger->setLogLevel($this->options['verbose']);
     $logger->setXincLogFile($this->options['log-file']);
 }