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


PHP Package::getVersion方法代码示例

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


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

示例1: addPackage

 /**
  * Ajoute un paquet a la liste des paquets installes.
  * @param Package $package Le paquet a ajouter.
  */
 public function addPackage(Package $package)
 {
     //Si le paquet est deja installe, on enleve l'ancien
     if ($this->isPackage($package->getName())) {
         $oldPackage = $this->getPackage($package->getName());
         $oldPackage->remove();
     }
     $xml = new \DOMDocument('1.0');
     if ($this->webos->managers()->get('File')->exists($this->source . '/packages.xml')) {
         $xml->loadXML($this->webos->managers()->get('File')->get($this->source . '/packages.xml')->contents());
         $root = $xml->getElementsByTagName('packages')->item(0);
     } else {
         $root = $xml->createElement('packages');
         $xml->appendChild($root);
     }
     $element = $xml->createElement('package');
     $root->appendChild($element);
     $name = $xml->createAttribute('name');
     $name->appendChild($xml->createTextNode($package->getName()));
     $element->appendChild($name);
     $version = $xml->createAttribute('version');
     $version->appendChild($xml->createTextNode($package->getVersion()->getVersion()));
     $element->appendChild($version);
     $this->webos->managers()->get('File')->get($this->source . '/packages.xml')->setContents($xml->saveXML());
     $xml = new \DOMDocument('1.0');
     $root = $xml->createElement('package');
     $xml->appendChild($root);
     $xml_attributes = $xml->createElement('attributes');
     $root->appendChild($xml_attributes);
     $attributes = $package->getAttributes();
     $attributes['installed_time'] = time();
     $attributes['source'] = $package->getRepositorySource();
     foreach ($attributes as $attribute => $value) {
         $node = $xml->createElement('attribute');
         $xml_attributes->appendChild($node);
         $name = $xml->createAttribute('name');
         $name->appendChild($xml->createTextNode($attribute));
         $node->appendChild($name);
         $val = $xml->createAttribute('value');
         $val->appendChild($xml->createTextNode($value));
         $node->appendChild($val);
     }
     $files = $package->getFiles();
     $xml_files = $xml->createElement('files');
     $root->appendChild($xml_files);
     foreach ($files as $file) {
         $node = $xml->createElement('file');
         $xml_files->appendChild($node);
         $path = $xml->createAttribute('path');
         $path->appendChild($xml->createTextNode($file));
         $node->appendChild($path);
     }
     $this->webos->managers()->get('File')->createFile($this->source . '/packages/' . $package->getName() . '.xml')->setContents($xml->saveXML());
     $newPackage = new InstalledPackage($this->webos, $this, $package->getName());
     $this->packages[$package->getName()] = $newPackage;
 }
开发者ID:Tiger66639,项目名称:symbiose-raspberrypi,代码行数:60,代码来源:LocalRepository.class.php

示例2: isValidUpdate

 /**
  * Checks if the new package is compatible with
  * the package that is about to be updated.
  *
  * @return 	boolean 	isValidUpdate
  */
 public function isValidUpdate()
 {
     // Check name of the installed package against the name of the update. Both must be identical.
     if ($this->packageInfo['name'] != $this->package->getPackage()) {
         return false;
     }
     // Check if the version number of the installed package is lower than the version number to which
     // it's about to be updated.
     if (Package::compareVersion($this->packageInfo['version'], $this->package->getVersion()) != 1) {
         return false;
     }
     // Check if the package provides an instructions block for the update from the installed package version
     if ($this->update === null) {
         return false;
     }
     return true;
 }
开发者ID:joaocustodio,项目名称:EmuDevstore-1,代码行数:23,代码来源:PackageArchive.class.php

示例3: updatePackage

 /**
  * Updates an existing package.
  * 
  * @param	integer		$packageID
  * @param	string		$version	new package version
  */
 protected function updatePackage($packageID, $version)
 {
     // get package info
     $package = new Package($packageID);
     // get current package version
     $packageVersion = $package->getVersion();
     if (isset($this->virtualPackageVersions[$packageID])) {
         $packageVersion = $this->virtualPackageVersions[$packageID];
         // check virtual package version
         if (Package::compareVersion($packageVersion, $version, '>=')) {
             // virtual package version is greater than requested version
             // skip package update
             return;
         }
     }
     // get highest version of the required major release
     if (preg_match('/(\\d+\\.\\d+\\.)/', $version, $match)) {
         $packageVersions = array();
         $sql = "SELECT\tDISTINCT packageVersion\n\t\t\t\tFROM\twcf" . WCF_N . "_package_update_version\n\t\t\t\tWHERE\tpackageUpdateID IN (\n\t\t\t\t\t\tSELECT\tpackageUpdateID\n\t\t\t\t\t\tFROM\twcf" . WCF_N . "_package_update\n\t\t\t\t\t\tWHERE\tpackage = '" . escapeString($package->getPackage()) . "'\n\t\t\t\t\t)\n\t\t\t\t\tAND packageVersion LIKE '" . escapeString($match[1]) . "%'";
         $result = WCF::getDB()->sendQuery($sql);
         while ($row = WCF::getDB()->fetchArray($result)) {
             $packageVersions[] = $row['packageVersion'];
         }
         if (count($packageVersions) > 1) {
             // sort by version number
             usort($packageVersions, array('Package', 'compareVersion'));
             // get highest version
             $version = array_pop($packageVersions);
         }
     }
     // get all fromversion
     $fromversions = array();
     $sql = "SELECT\t\tpuv.packageVersion, puf.fromversion\n\t\t\tFROM\t\twcf" . WCF_N . "_package_update_fromversion puf\n\t\t\tLEFT JOIN\twcf" . WCF_N . "_package_update_version puv\n\t\t\tON\t\t(puv.packageUpdateVersionID = puf.packageUpdateVersionID)\n\t\t\tWHERE\t\tpuf.packageUpdateVersionID IN (\n\t\t\t\t\t\tSELECT\tpackageUpdateVersionID\n\t\t\t\t\t\tFROM\twcf" . WCF_N . "_package_update_version\n\t\t\t\t\t\tWHERE \tpackageUpdateID IN (\n\t\t\t\t\t\t\tSELECT\tpackageUpdateID\n\t\t\t\t\t\t\tFROM\twcf" . WCF_N . "_package_update\n\t\t\t\t\t\t\tWHERE\tpackage = '" . escapeString($package->getPackage()) . "'\n\t\t\t\t\t\t)\n\t\t\t\t\t)";
     $result = WCF::getDB()->sendQuery($sql);
     while ($row = WCF::getDB()->fetchArray($result)) {
         if (!isset($fromversions[$row['packageVersion']])) {
             $fromversions[$row['packageVersion']] = array();
         }
         $fromversions[$row['packageVersion']][$row['fromversion']] = $row['fromversion'];
     }
     // sort by version number
     uksort($fromversions, array('Package', 'compareVersion'));
     // find shortest update thread
     $updateThread = self::findShortestUpdateThread($package->getPackage(), $fromversions, $packageVersion, $version);
     // process update thread
     foreach ($updateThread as $fromversion => $toVersion) {
         $packageUpdateVersions = self::getPackageUpdateVersions($package->getPackage(), $toVersion);
         // resolve requirements
         $this->resolveRequirements($packageUpdateVersions[0]['packageUpdateVersionID']);
         // download package
         $download = '';
         if ($this->download) {
             $download = $this->downloadPackage($package->getPackage(), $packageUpdateVersions);
         }
         // add to stack
         $this->packageInstallationStack[] = array('packageName' => $package->getName(), 'instanceNo' => $package->getInstanceNo(), 'fromversion' => $fromversion, 'toVersion' => $toVersion, 'package' => $package->getPackage(), 'packageID' => $packageID, 'archive' => $download, 'action' => 'update');
         // update virtual versions
         $this->virtualPackageVersions[$packageID] = $toVersion;
     }
 }
开发者ID:CaribeSoy,项目名称:contest-wcf,代码行数:66,代码来源:PackageUpdate.class.php

示例4: addPackage

 /**
  * Add package
  *
  * @param Package $package
  * @return void
  */
 public function addPackage($package)
 {
     $channel = $this->chanName($package->getChannel());
     $name = $package->getName();
     $record = array(self::K_VER => $package->getVersion(), self::K_STATE => $package->getStability(), self::K_XML => $package->getPackageXml(), self::K_NAME => $name, self::K_DEPS => array(), self::K_PACK_DEPS => array());
     $this->setPackageRecord($channel, $name, $record);
     $this->setPackageDependencies($channel, $name, $package->getDependencyPackages());
     $this->save();
 }
开发者ID:Atlis,项目名称:docker-magento2,代码行数:15,代码来源:Singleconfig.php

示例5: writeConfigFile

 /**
  * Writes the config.inc.php for a standalone application.
  * 
  * @param	integer		$packageID
  */
 public static function writeConfigFile($packageID)
 {
     $package = new Package($packageID);
     $packageDir = FileUtil::addTrailingSlash(FileUtil::getRealPath(WCF_DIR . $package->getDir()));
     $file = new File($packageDir . PackageInstallation::CONFIG_FILE);
     $file->write("<?php\n");
     $currentPrefix = strtoupper($package->getAbbreviation());
     // get dependencies (only standalones)
     $sql = "SELECT\t\tpackage.*, IF(package.packageID = " . $packageID . ", 1, 0) AS sortOrder\n\t\t\tFROM\t\twcf" . WCF_N . "_package_dependency package_dependency\n\t\t\tLEFT JOIN\twcf" . WCF_N . "_package package\n\t\t\tON\t\t(package.packageID = package_dependency.dependency)\n\t\t\tWHERE\t\tpackage_dependency.packageID = " . $packageID . "\n\t\t\t\t\tAND package.standalone = 1\n\t\t\t\t\tAND package.packageDir <> ''\n\t\t\tORDER BY\tsortOrder DESC,\n\t\t\t\t\tpackage_dependency.priority DESC";
     $result = WCF::getDB()->sendQuery($sql);
     while ($row = WCF::getDB()->fetchArray($result)) {
         $dependency = new Package(null, $row);
         $dependencyDir = FileUtil::addTrailingSlash(FileUtil::getRealPath(WCF_DIR . $dependency->getDir()));
         $prefix = strtoupper($dependency->getAbbreviation());
         $file->write("// " . $dependency->getPackage() . " vars\n");
         $file->write("// " . strtolower($prefix) . "\n");
         $file->write("if (!defined('" . $prefix . "_DIR')) define('" . $prefix . "_DIR', " . ($dependency->getPackageID() == $package->getPackageID() ? "dirname(__FILE__).'/'" : "'" . $dependencyDir . "'") . ");\n");
         $file->write("if (!defined('RELATIVE_" . $prefix . "_DIR')) define('RELATIVE_" . $prefix . "_DIR', " . ($dependency->getPackageID() == $package->getPackageID() ? "''" : "RELATIVE_" . $currentPrefix . "_DIR.'" . FileUtil::getRelativePath($packageDir, $dependencyDir) . "'") . ");\n");
         $file->write("if (!defined('" . $prefix . "_N')) define('" . $prefix . "_N', '" . WCF_N . "_" . $dependency->getInstanceNo() . "');\n");
         $file->write("\$packageDirs[] = " . $prefix . "_DIR;\n");
         $file->write("\n");
     }
     // write general information
     $file->write("// general info\n");
     $file->write("if (!defined('RELATIVE_WCF_DIR'))\tdefine('RELATIVE_WCF_DIR', RELATIVE_" . $currentPrefix . "_DIR.'" . FileUtil::getRelativePath($packageDir, WCF_DIR) . "');\n");
     $file->write("if (!defined('PACKAGE_ID')) define('PACKAGE_ID', " . $package->getPackageID() . ");\n");
     $file->write("if (!defined('PACKAGE_NAME')) define('PACKAGE_NAME', '" . str_replace("'", "\\'", $package->getName()) . "');\n");
     $file->write("if (!defined('PACKAGE_VERSION')) define('PACKAGE_VERSION', '" . $package->getVersion() . "');\n");
     // write end
     $file->write("?>");
     $file->close();
 }
开发者ID:CaribeSoy,项目名称:contest-wcf,代码行数:37,代码来源:Package.class.php


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