コード例 #1
0
 public static function newNullPackage()
 {
     if (!isset($nullPackage)) {
         self::$nullPackage = new NullPackage();
     }
     return self::$nullPackage;
 }
コード例 #2
0
ファイル: PackageTest.php プロジェクト: Slayug/castor
 protected function setUp()
 {
     parent::setUp();
     $factory = new PackageFactory();
     $this->package = $factory->newInstance(['fallback' => 'Vendor.Fallback', 'formatter' => 'intl', 'messages' => ['ERR_NO_SUCH_OPTION' => "The option {option} is not recognized."]]);
 }
コード例 #3
0
 /**
  * Parse the specified build log, constructing from it a collection
  * of BuildEvent objects representing the events.
  *
  * @param log  (Object) Root element of a SimpleXMLElement DOM
  * @param builds  (Array) Builds collection to be populated.
  * @return  (Boolean) @c TRUE iff parse completed successfully.
  */
 private static function parseBuildLogDOM(&$log, &$builds)
 {
     if (!$log instanceof SimpleXMLElement) {
         throw new Exception('Received invalid build log');
     }
     // For each build event.
     foreach ($log->children() as $log_event) {
         try {
             $build = self::parseBuildEvent($log_event);
             foreach ($log_event->children() as $child) {
                 switch ($child->getName()) {
                     case 'package':
                         try {
                             $pack = PackageFactory::newFromSimpleXMLElement($child, $build->releaseTypeId());
                             $pack->setBuildUniqueId($build->uniqueId());
                             if ($pack instanceof iDownloadable) {
                                 $pack->setReleaseDate($build->startDate());
                             }
                             if ($build->hasReleaseNotesUri()) {
                                 $pack->setReleaseNotesUri($build->releaseNotesUri());
                             }
                             if ($build->hasReleaseChangeLogUri()) {
                                 $pack->setReleaseChangeLogUri($build->releaseChangeLogUri());
                             }
                             $build->addPackage($pack);
                         } catch (Exception $e) {
                             /// @todo Log exception.
                         }
                         break;
                     case 'commits':
                         $log_commits = $child;
                         foreach ($log_commits->children() as $child) {
                             if ($child->getName() !== 'commit') {
                                 continue;
                             }
                             try {
                                 $commit = self::parseCommit($child);
                                 $build->addCommit($commit);
                             } catch (Exception $e) {
                                 /// @todo Log exception.
                             }
                         }
                         break;
                     default:
                         break;
                 }
             }
             // Add this new BuildEvent to the collection.
             $builds[] = $build;
         } catch (Exception $e) {
             /// @todo Log exception.
         }
     }
     return TRUE;
 }
コード例 #4
0
 /**
  * One-time initialization of the Packages collection.
  */
 private function initPackages()
 {
     // Init the special case 'null' package.
     self::$nullPack = PackageFactory::newNullPackage();
     // Init collections.
     $this->rebuildPackages();
 }