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


PHP PackageManager::getInstalledPackage方法代码示例

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


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

示例1: checkCondition

 /**
  * Проверяет условия указанные в теге condition.
  *
  * В данной момент реализована проверка установленного пакета
  *
  * @param DOMNode 
  * @return bool
  */
 private function checkCondition(DOMNode $node)
 {
     IO::info('Check Condition ', false);
     $attr = $node->attributes;
     $packageName = is_null($attr->getNamedItem('package')) ? null : $attr->getNamedItem('package')->nodeValue;
     if (!is_null($packageName)) {
         $version = is_null($attr->getNamedItem('version')) ? null : $attr->getNamedItem('version')->nodeValue;
         $rel = is_null($attr->getNamedItem('rel')) ? null : Deps::normalizeRel($attr->getNamedItem('rel')->nodeValue);
         if (is_null($version) && $rel != '!=') {
             $version = '0.0';
             $rel = '>=';
         } elseif (is_null($rel)) {
             $rel = '=';
         }
         io::info($packageName . ' ' . $rel . ' ' . $version . "\t", false);
         $p = PackageManager::getInstalledPackage($packageName);
         if ($rel == '!=') {
             $res = $p === false;
         } elseif ($p !== false) {
             $res = version_compare($p->version, $version, $rel);
         } else {
             $res = false;
         }
         io::info('', $res ? IO::MESSAGE_OK : IO::MESSAGE_FAIL);
         return $res;
     }
 }
开发者ID:point,项目名称:cassea,代码行数:35,代码来源:Deployer.php

示例2: isNoNeeded

 /**
  * Проверять возможность удаления указанного пакета.
  *
  * Если существует пакет который зависит от данного то удаление невозможно.
  *
  * Массив пакетов для удаления. Если удаление невозможно вернет false.
  *
  * @param $nvr
  * @param array $unstatisfied
  * @return array of packages | bool false 
  */
 static function isNoNeeded($nvr, &$unstatisfied)
 {
     $name = $nvr['name'];
     $pseq = PackageManager::getPackageSequence();
     $nvr['rel'] = Deps::normalizeRel($nvr['rel']);
     if ($nvr['rel'] == '=') {
         $nvr['rel'] = '>=';
     }
     $stayedList = array();
     // версии которые останцтся после уддаления
     $removedList = array();
     // версии которые необходимо удалить
     $addToRemovedList = false;
     $checkList = array();
     // пакеты которые необходимо проверить на совместимость
     for ($i = 0, $c = count($pseq); $i < $c; $i++) {
         if ($pseq[$i]['name'] != $name) {
             if ($addToRemovedList) {
                 $checkList[] = $pseq[$i];
             }
         } else {
             if (version_compare($pseq[$i]['version'], $nvr['version'], $nvr['rel'])) {
                 $addToRemovedList = true;
             }
             if ($addToRemovedList) {
                 $removedList[] = PackageManager::getInstalledPackage($pseq[$i]['name'], $pseq[$i]['version']);
             } else {
                 $stayedList[] = $pseq[$i];
             }
         }
     }
     /*
             io::out('Stayed list : '.$name, false);
             foreach($stayedList as $a) io::out($a['name'].'='.$a['version']. ' ', false);
             io::out();
     
             io::out('removes list : ', false);
             foreach($removedList as $a) io::out($a->version. ' ', false);
             io::out();
     
             io::out('CheckList : ', false);
             foreach($checkList as $a) io::out($a['name'].' '.$a['version'].', ', false);
             io::out();
     */
     foreach ($checkList as $pnvr) {
         $packageDeps = PackageManager::getInstalledPackage($pnvr['name'], $pnvr['version'])->deps['packages'];
         foreach ($packageDeps as $p) {
             if ($p['name'] == $name) {
                 $statisfy = false;
                 $luns = array();
                 // localUnstatisfied
                 //io::out($nvr['name'].' '.$nvr['version']);
                 //print_r($p);
                 // Все версии пакета будут удалены, а пакет фигурирует в зависимостях
                 if (count($stayedList) == 0) {
                     $luns[$p['name'] . ' ' . $p['rel'] . ' ' . $p['version']] = 1;
                 } else {
                     foreach ($stayedList as $stayedPackage) {
                         if (!version_compare($stayedPackage['version'], $p['version'], $p['rel'])) {
                             $luns[$p['name'] . ' ' . $p['rel'] . ' ' . $p['version']] = 1;
                         } else {
                             $statisfy = true;
                             break;
                         }
                     }
                 }
                 // если после удаления не останется ниодного пакета удовлетворяющего зависимости,
                 // то добавляем в массив нудовлетворенных зависимостей $luns
                 if (!$statisfy) {
                     $unstatisfied[$pnvr['name'] . '(' . $pnvr['version'] . ')'] = $luns;
                 }
             }
         }
     }
     return count($unstatisfied) ? false : array_reverse($removedList);
 }
开发者ID:point,项目名称:cassea,代码行数:87,代码来源:Deps.php

示例3: cmdInfo

 /**
  * Информация об указанном пакете 
  */
 function cmdInfo()
 {
     if (($package = ArgsHolder::get()->shiftCommand(false)) === false) {
         return IO::out('Specify package file', IO::MESSAGE_FAIL) | 1;
     }
     if (($version = ArgsHolder::get()->shiftCommand()) === false) {
         $version = null;
     }
     try {
         PackageManager::get()->startup();
         $width = 20;
         $p = PackageManager::getInstalledPackage(trim($package, '\'"'), $version);
         if ($p !== false) {
             $r = array('Name', 'Version', 'Summary', 'Mantainer', 'Tags');
             foreach ($r as $k) {
                 $pname = strtolower($k);
                 io::out(sprintf('%18s: %s', $k, $p->{$pname}));
             }
             // description
             $str = '';
             if (trim($p->description) != '') {
                 foreach (explode(PHP_EOL . PHP_EOL, trim($p->description)) as $aa) {
                     $str .= chunk_split(implode(' ', explode(PHP_EOL, $aa))) . PHP_EOL;
                 }
                 $a = explode(PHP_EOL, $str);
                 io::out(sprintf('%18s: %s', 'Description', $a[0]));
                 for ($i = 1, $c = count($a); $i < $c; $i++) {
                     if (trim($a[$i]) != '') {
                         io::out(sprintf('%' . ($i ? $width : '') . 's%s', '', $a[$i]));
                     }
                 }
             }
             // deps
             $d = $p->deps;
             if (!is_null($php = $d['php'])) {
                 $as = 'PHP ' . $php['rel'] . ' ' . $php['version'];
             }
             if (count($ex = $d['phpExtensions'])) {
                 $as .= '; ' . implode(', ', $ex);
             }
             $a = isset($as) ? array($as) : array();
             if (count($inis = $d['phpIniValues'])) {
                 foreach ($inis as $i) {
                     $a[] = 'ini.' . $i['name'] . ' ' . $i['rel'] . ' ' . $i['value'];
                 }
             }
             if (count($pkgs = $d['packages'])) {
                 foreach ($pkgs as $i) {
                     $a[] = '' . $i['name'] . ' ' . $i['rel'] . ' ' . $i['version'];
                 }
             }
             io::out(sprintf('%18s: %s', 'Dependensies', count($a) ? $a[0] : ''));
             for ($i = 1, $c = count($a); $i < $c; $i++) {
                 io::out(sprintf('%' . ($i ? $width : '') . 's%s', '', $a[$i]));
             }
         } else {
             io::out('Given package ' . $package . (!is_null($version) ? "({$version})" : '') . ' not installed', IO::MESSAGE_FAIL);
         }
         PackageManager::get()->shutdown();
     } catch (Exception $e) {
         PackageManager::getRollback()->stepBack();
         return io::out($e->getMessage(), IO::MESSAGE_FAIL) | (is_null($e->getCode()) ? 2 : $e->getCode());
     }
 }
开发者ID:point,项目名称:cassea,代码行数:67,代码来源:PackageManagerFacade.php

示例4: install

 /**
  * Инсталяция пакета
  *
  * Пакет $package может быть представлен ввиде локального фала(~/mypackage.tbz),
  * имени пакета (admin) или ввиде имени пакет, версии и отношения (news>=2.0-alpha)
  *
  * @throw PackageManagerException, RepositoryListException
  * @param string $package
  */
 static function install($package)
 {
     // локальный файл
     if (($fp = realpath($package)) !== false) {
         if (($p = Package::isPackage(new File($fp, true))) !== false) {
             $package = $p;
         } else {
             throw new PackageManagerException('Given file (' . $package . ') isn\'t a well formed  package.');
         }
     }
     // зависимости
     io::out('~WHITE~Checking dependencies~~~');
     $installList = Deps::calculate($package);
     if ($installList === false) {
         throw new PackageManagerException('Невозможно удовлетворить зависимости, или не найдены требуемые пакеты.');
     } elseif ($installList instanceof Package) {
         return IO::out('Установленная версия пакета ' . $installList->name . ': ' . $installList->version) | 0;
     }
     $newPackages = array();
     $updatePackages = array();
     $installedPackages = array();
     $list = array();
     for ($i = 0, $c = count($installList); $i < $c; $i++) {
         $package = $installList[$i];
         if ($package->status != Package::INSTALLED) {
             $list[] = $package;
         }
         // for information oupput
         if ($package->status == Package::INSTALLED) {
             $installedPackages[] = $package;
         } else {
             if (false === ($p = PackageManager::getInstalledPackage($package->name))) {
                 $newPackages[] = $package;
             } else {
                 $updatePackages[] = $p;
             }
         }
     }
     foreach ($newPackages as $p) {
         $n[] = $p->name . '(' . $p->version . ')';
     }
     if (isset($n)) {
         io::out('New Packages: ' . implode(', ', $n));
     }
     foreach ($updatePackages as $p) {
         $u[] = $p->name . '(' . $p->version . ')';
     }
     if (isset($u)) {
         io::out('Packages to be updated: ' . implode(', ', $u));
     }
     foreach ($installedPackages as $p) {
         $inst[] = $p->name . '(' . $p->version . ')';
     }
     if (isset($inst)) {
         io::out('Installed Packages: ' . implode(', ', $inst));
     }
     // доставка
     $deployList = array();
     io::out('~WHITE~Fetching packages~~~');
     $dDir = self::getDownloadDir();
     foreach ($list as $package) {
         io::out($package->name . '_' . $package->version . ': ', false);
         $tFile = $dDir->getFile($package->name . '_' . $package->version . '.tbz');
         //look in downloaded dir
         $p = Package::isPackage($tFile);
         if ($p instanceof Package && $p->name == $package->name && $p->version == $package->version) {
             io::out('Already downloaded', false);
             $deployList[] = $p;
         } else {
             // откат для скачанногофайла
             PackageManager::getRollback()->push('delete', $tFile);
             $deployList[] = $package->delivery($tFile);
         }
         io::done();
     }
     try {
         foreach ($deployList as $p) {
             io::out('~WHITE~Deploying ' . $p->name . '(' . $p->version . '):~~~');
             $p->deploy();
             $p->file->move(PackageManager::getInstalledDir()->getFile($p->name . '_' . $p->version . '.tbz'));
             PackageManager::get()->packagesSequence->addPackage($p->name, $p->version);
         }
     } catch (Exception $e) {
         echo $e->getMessage();
         PackageManager::getRollback()->stepBack();
     }
     return;
 }
开发者ID:point,项目名称:cassea,代码行数:97,代码来源:PackageManager.php


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