Exemple #1
0
 /**
  * Parses the tasks/subtasks of a project-xml
  *
  * @param Xinc\Core\Models\Project $project
  * @param SimpleXmlElement $element
  */
 private function parseTasks($project, $element)
 {
     foreach ($element as $taskName => $task) {
         $taskObject = clone \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, $project);
             } else {
                 throw new \Exception('Trying to set "' . $name . '" on task "' . $taskName . '" failed. No such setter.');
             }
         }
         $this->parseTasks($project, $task);
         if (!$taskObject->validate()) {
             throw new \Exception('Error validating config.xml for task: ' . $taskObject->getName());
         }
         $project->addProcess($taskObject->getPluginSlot(), $taskObject);
     }
 }
Exemple #2
0
/**
 * Xinc - Continuous Integration.
 *
 * PHP version 5
 *
 * @category   Development
 * @package    Xinc.Trigger
 * @author     Alexander Opitz <opitz.alexander@gmail.com>
 * @copyright  2014 Alexander Opitz, Leipzig
 * @license    http://www.gnu.org/copyleft/lgpl.html GNU/LGPL, see license.php
 *             This file is part of Xinc.
 *             Xinc is free software; you can redistribute it and/or modify
 *             it under the terms of the GNU Lesser General Public License as
 *             published by the Free Software Foundation; either version 2.1 of
 *             the License, or (at your option) any later version.
 *
 *             Xinc is distributed in the hope that it will be useful,
 *             but WITHOUT ANY WARRANTY; without even the implied warranty of
 *             MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *             GNU Lesser General Public License for more details.
 *
 *             You should have received a copy of the GNU Lesser General Public
 *             License along with Xinc, write to the Free Software Foundation,
 *             Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 * @link       http://code.google.com/p/xinc/
 */
\Xinc\Core\Task\Registry::getInstance()->register('trigger', new \Xinc\Trigger\Task\Triggers());
\Xinc\Core\Task\Registry::getInstance()->register('cron', new \Xinc\Trigger\Task\Cron());
\Xinc\Core\Task\Registry::getInstance()->register('schedule', new \Xinc\Trigger\Task\Scheduler());
\Xinc\Core\Task\Registry::getInstance()->register('sensor', new \Xinc\Trigger\Task\Sensor());
Exemple #3
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;
         }
     }
 }