当前位置: 首页>>代码示例>>PHP>>正文


PHP Package::isValidPackageName方法代码示例

本文整理汇总了PHP中Package::isValidPackageName方法的典型用法代码示例。如果您正苦于以下问题:PHP Package::isValidPackageName方法的具体用法?PHP Package::isValidPackageName怎么用?PHP Package::isValidPackageName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Package的用法示例。


在下文中一共展示了Package::isValidPackageName方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: package

 /**
  * @param string $name
  * @return static
  */
 public function package($name)
 {
     if (isset($this->dependencies[$name])) {
         return $this;
     }
     if (!Package::isValidPackageName($name)) {
         throw new \Exception('Package name is invalid');
     }
     $package = Config::instance()->packageDefinitionManager()->get($name);
     if (Config::instance()->compiler()) {
         $package = Config::instance()->compiler()->compilePackage($package);
     }
     $this->appendPackage($package);
     return $this;
 }
开发者ID:oktopost,项目名称:aquarium,代码行数:19,代码来源:Manager.php

示例2: getPackageData

 /**
  * Reads out PackageData
  *
  * @param	array<array>	$package	the package array generated in self::readPackages()
  * @param	mixed		$version	the version to check
  * @param	mixed		$field		should only one information be returned?
  * @return	mixed				either an array with data, or the data wanted in $field
  */
 public static function getPackageData(array $package, $version = null, $field = null)
 {
     $data = array();
     if ($version === null) {
         // read firest package for general information
         $key = array_keys($package);
         $xml = $package[$key[0]]['xml']->getElementTree('data');
     } else {
         $xml = $package[$version]['xml']->getElementTree('data');
     }
     $data['packageIdentifier'] = $xml['attrs']['name'];
     $data['isUpdate'] = false;
     $data['plugin'] = $data['packagename'] = $data['packagedescription'] = $data['standalone'] = null;
     foreach ($xml['children'] as $child) {
         switch (StringUtil::toLowerCase($child['name'])) {
             // read in package information
             case 'packageinformation':
                 foreach ($child['children'] as $packageInformation) {
                     switch (StringUtil::toLowerCase($packageInformation['name'])) {
                         case 'packagename':
                             if (!isset($data['packageName'])) {
                                 $data['packageName'] = $packageInformation['cdata'];
                             }
                             break;
                         case 'packagedescription':
                             if (!isset($data['packageDescription'])) {
                                 $data['packageDescription'] = $packageInformation['cdata'];
                             }
                             break;
                         case 'standalone':
                             $data['standalone'] = intval($packageInformation['cdata']);
                             break;
                         case 'promptparent':
                         case 'plugin':
                             if (!Package::isValidPackageName($packageInformation['cdata'])) {
                                 $data['plugin'] = null;
                             }
                             $data['plugin'] = $packageInformation['cdata'];
                             break;
                     }
                 }
                 break;
                 // read in author information
             // read in author information
             case 'authorinformation':
                 foreach ($child['children'] as $authorInformation) {
                     switch (StringUtil::toLowerCase($authorInformation['name'])) {
                         case 'author':
                             $data['author'] = $authorInformation['cdata'];
                             break;
                         case 'authorurl':
                             $data['authorURL'] = $authorInformation['cdata'];
                             break;
                     }
                 }
                 break;
                 // read in requirements
             // read in requirements
             case 'requiredpackages':
                 foreach ($child['children'] as $requiredPackage) {
                     if (Package::isValidPackageName($requiredPackage['cdata'])) {
                         $data['requirements'][$requiredPackage['cdata']] = array('name' => $requiredPackage['cdata']) + $requiredPackage['attrs'];
                     }
                 }
                 break;
                 // get installation and update instructions
             // get installation and update instructions
             case 'instructions':
                 if ($child['attrs']['type'] == 'update') {
                     $data['isUpdate'] = true;
                     $data['fromVersions'][] = $child['attrs']['fromversion'];
                 }
                 break;
         }
     }
     if ($field === null) {
         return $data;
     } else {
         return $data[$field];
     }
 }
开发者ID:ZerGabriel,项目名称:PackageBuilder,代码行数:89,代码来源:CacheBuilderUpdateServer.class.php

示例3: parsePackageUpdateXML

 /**
  * Parses a stream containing info from a packages_update.xml.
  *
  * @param	string		$content
  * @return	array		$allNewPackages
  */
 protected static function parsePackageUpdateXML($content)
 {
     // load xml document
     $xmlObj = new XML();
     $xmlObj->loadString($content);
     // load the <section> tag (which must be the root element).
     $xml = $xmlObj->getElementTree('section');
     $encoding = $xmlObj->getEncoding();
     unset($xmlObj);
     // loop through <package> tags inside the <section> tag.
     $allNewPackages = array();
     foreach ($xml['children'] as $child) {
         // name attribute is missing, thus this package is not valid
         if (!isset($child['attrs']['name']) || !$child['attrs']['name']) {
             throw new SystemException("required 'name' attribute for 'package' tag is missing", 13001);
         }
         // the "name" attribute of this <package> tag must be a valid package identifier.
         if (!Package::isValidPackageName($child['attrs']['name'])) {
             throw new SystemException("'" . $child['attrs']['name'] . "' is not a valid package name.", 18004);
         }
         $package = $child['attrs']['name'];
         // parse packages_update.xml and fill $packageInfo.
         $packageInfo = self::parsePackageUpdateXMLBlock($child, $package);
         // convert enconding
         if ($encoding != CHARSET) {
             $packageInfo['packageName'] = StringUtil::convertEncoding($encoding, CHARSET, $packageInfo['packageName']);
             $packageInfo['packageDescription'] = StringUtil::convertEncoding($encoding, CHARSET, $packageInfo['packageDescription']);
             $packageInfo['author'] = StringUtil::convertEncoding($encoding, CHARSET, $packageInfo['author']);
             $packageInfo['authorURL'] = StringUtil::convertEncoding($encoding, CHARSET, $packageInfo['authorURL']);
         }
         $allNewPackages[$child['attrs']['name']] = $packageInfo;
     }
     unset($xml);
     return $allNewPackages;
 }
开发者ID:CaribeSoy,项目名称:contest-wcf,代码行数:41,代码来源:PackageUpdate.class.php

示例4: readPackageInfo

 /**
  * Extracts information about this package (parses package.xml).
  */
 protected function readPackageInfo()
 {
     // search package.xml in package archive
     // throw error message if not found
     if ($this->tar->getIndexByFilename(self::INFO_FILE) === false) {
         throw new SystemException("package information file '" . self::INFO_FILE . "' not found in '" . $this->archive . "'", 13000);
     }
     // extract package.xml, parse with SimpleXML
     // and compile an array with XML::getElementTree()
     $xml = new XML();
     try {
         $xml->loadString($this->tar->extractToString(self::INFO_FILE));
     } catch (Exception $e) {
         // bugfix to avoid file caching problems
         $xml->loadString($this->tar->extractToString(self::INFO_FILE));
     }
     $xmlContent = $xml->getElementTree('package');
     // name attribute is missing, thus this package is not valid
     if (!isset($xmlContent['attrs']['name']) || !$xmlContent['attrs']['name']) {
         throw new SystemException("required 'name' attribute for 'package' tag is missing in " . self::INFO_FILE, 13001);
     }
     // package name is not a valid package identifier
     if (!Package::isValidPackageName($xmlContent['attrs']['name'])) {
         throw new SystemException("'" . $xmlContent['attrs']['name'] . "' is not a valid package name.", 13002);
     }
     // assign name attribute and loop through child tags
     $this->packageInfo['name'] = $xmlContent['attrs']['name'];
     foreach ($xmlContent['children'] as $child) {
         switch (StringUtil::toLowerCase($child['name'])) {
             // read in package information
             case 'packageinformation':
                 foreach ($child['children'] as $packageInformation) {
                     switch (StringUtil::toLowerCase($packageInformation['name'])) {
                         case 'packagename':
                             if (!isset($this->packageInfo['packageName'])) {
                                 $this->packageInfo['packageName'] = array();
                             }
                             if (isset($packageInformation['attrs']['language'])) {
                                 $languageCode = $packageInformation['attrs']['language'];
                             } else {
                                 if (isset($packageInformation['attrs']['languagecode'])) {
                                     $languageCode = $packageInformation['attrs']['languagecode'];
                                 } else {
                                     $languageCode = 'default';
                                 }
                             }
                             $this->packageInfo['packageName'][$languageCode] = $packageInformation['cdata'];
                             break;
                         case 'packagedescription':
                             if (!isset($this->packageInfo['packageDescription'])) {
                                 $this->packageInfo['packageDescription'] = array();
                             }
                             if (isset($packageInformation['attrs']['language'])) {
                                 $languageCode = $packageInformation['attrs']['language'];
                             } else {
                                 if (isset($packageInformation['attrs']['languagecode'])) {
                                     $languageCode = $packageInformation['attrs']['languagecode'];
                                 } else {
                                     $languageCode = 'default';
                                 }
                             }
                             $this->packageInfo['packageDescription'][$languageCode] = $packageInformation['cdata'];
                             break;
                         case 'isunique':
                             $this->packageInfo['isUnique'] = intval($packageInformation['cdata']);
                             break;
                         case 'standalone':
                             $this->packageInfo['standalone'] = intval($packageInformation['cdata']);
                             break;
                         case 'promptparent':
                         case 'plugin':
                             if ($packageInformation['cdata'] != 0 && !Package::isValidPackageName($packageInformation['cdata'])) {
                                 throw new SystemException("'" . $packageInformation['cdata'] . "' is not a valid package name.", 13002);
                             }
                             $this->packageInfo['plugin'] = $packageInformation['cdata'];
                             break;
                         case 'version':
                             $this->packageInfo['version'] = $packageInformation['cdata'];
                             break;
                         case 'date':
                             $this->packageInfo['date'] = @strtotime($packageInformation['cdata']);
                             if ($this->packageInfo['date'] === -1 || $this->packageInfo['date'] === false) {
                                 throw new SystemException("invalid dateformat '" . $packageInformation['cdata'] . "' in package.xml", 13003);
                             }
                             $this->packageInfo['date'] += 43201;
                             break;
                         case 'packageurl':
                             $this->packageInfo['packageURL'] = $packageInformation['cdata'];
                             break;
                     }
                 }
                 break;
                 // read in author information
             // read in author information
             case 'authorinformation':
                 foreach ($child['children'] as $authorInformation) {
                     switch (StringUtil::toLowerCase($authorInformation['name'])) {
//.........这里部分代码省略.........
开发者ID:joaocustodio,项目名称:EmuDevstore-1,代码行数:101,代码来源:PackageArchive.class.php


注:本文中的Package::isValidPackageName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。