/** * Parse a new BuildEvent from a SimpleXMLElement. * * @param $log_event (Object) SimpleXMLElement node to be "parsed". * @return (object) Resultant BuildEvent object. */ private static function parseBuildEvent(&$log_event) { if (!$log_event instanceof SimpleXMLElement) { throw new Exception('Received invalid log_event'); } $uniqueId = (int) $log_event->uniqueId; $startDate = strtotime(clean_text($log_event->startDate)); $authorName = clean_text($log_event->authorName); $authorEmail = clean_text($log_event->authorEmail); if (!empty($log_event->releaseType)) { $releaseType = BuildRepositoryPlugin::parseReleaseType(clean_text($log_event->releaseType)); } else { $releaseType = RT_UNSTABLE; } $event = new BuildEvent($uniqueId, $startDate, $authorName, $authorEmail, $releaseType); if (!empty($log_event->releaseNotes)) { $event->setReleaseNotesUri(clean_text($log_event->releaseNotes)); } if (!empty($log_event->changeLog)) { $event->setReleaseChangeLogUri(clean_text($log_event->changeLog)); } return $event; }
/** * Produce a indexable directory of BuildEvents from the Packages * collection, grouping them according to the version number of the * 'Doomsday' packages those events produced. * * The version number (string) is used as key to each record. * * @param matrix (Array) will be populated with new records. * @return (Mixed) FALSE if no packages were added to the matrix * otherwise the number of added packages (integer). */ private function populateReleases(&$releases) { if (!is_array($releases)) { throw new Exception('populateReleases: Invalid matrix argument, array expected.'); } if (!isset($this->packages)) { return FALSE; } // Running total of the number of events we add to the matrix. $numEventsAdded = (int) 0; foreach ($this->packages as &$pack) { // We are only interested in the 'Doomsday' packages. if ($pack->title() !== 'Doomsday') { continue; } // Have we encountered this version before?. $versionText = "{$pack->version()}"; $key = array_casekey_exists($versionText, $releases); if ($key === false) { // Not yet construct a new record and associate it // in the release list using the version number as the key. $key = ucwords($versionText); $releases[$key] = $this->newReleaseInfo($key); $releaseInfo =& $releases[$key]; } else { $releaseInfo =& $releases[$versionText]; } $build = NULL; // Is this package a product of the autobuilder? if ($pack instanceof iBuilderProduct) { // Yes; we have "real" BuildEvent we can link with this. $buildUniqueId = $pack->buildUniqueId(); $build = $this->buildByUniqueId($buildUniqueId); } else { // No - this must be a symbolic package. // We'll instantiate a symbolic BuildEvent for this. $build = new BuildEvent(0, $pack->hasReleaseDate() ? $pack->releaseDate() : strtotime('Jan 8, 2005'), 'skyjake', '*****@*****.**', RT_STABLE); if ($pack->hasReleaseNotesUri()) { $build->setReleaseNotesUri($pack->releaseNotesUri()); } if ($pack->hasReleaseChangeLogUri()) { $build->setReleaseChangeLogUri($pack->releaseChangeLogUri()); } $build->addPackage($pack); } if (!$build instanceof BuildEvent) { continue; } // Odd... // Is a build event already present for this release version? $latestBuild = isset($releaseInfo['latestBuild']) ? $releaseInfo['latestBuild'] : NULL; if ($latestBuild instanceof BuildEvent) { // Is this a newer build? if ($build->uniqueId() > $latestBuild->uniqueId()) { $releaseInfo['latestBuild'] = $build; } } else { $releaseInfo['latestBuild'] = $build; } // Promote the status of the release due to this package? $releaseTypeId = $build->releaseTypeId(); if ($releaseTypeId > $releaseInfo['releaseTypeId']) { $releaseInfo['releaseTypeId'] = $releaseTypeId; } } return $numEventsAdded; }