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


PHP PEAR_DependencyDB::getDependencies方法代码示例

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


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

示例1: validatePackageUninstall

 /**
  * Verify that uninstalling packages passed in to command line is OK.
  *
  * @param PEAR_Installer $dl
  * @return PEAR_Error|true
  */
 function validatePackageUninstall(&$dl)
 {
     if (PEAR::isError($this->_dependencydb)) {
         return $this->_dependencydb;
     }
     $params = array();
     // construct an array of "downloaded" packages to fool the package dependency checker
     // into using these to validate uninstalls of circular dependencies
     $downloaded =& $dl->getUninstallPackages();
     foreach ($downloaded as $i => $pf) {
         if (!class_exists('PEAR_Downloader_Package')) {
             require_once 'PEAR/Downloader/Package.php';
         }
         $dp =& new PEAR_Downloader_Package($dl);
         $dp->setPackageFile($downloaded[$i]);
         $params[$i] =& $dp;
     }
     // check cache
     $memyselfandI = strtolower($this->_currentPackage['channel']) . '/' . strtolower($this->_currentPackage['package']);
     if (isset($dl->___uninstall_package_cache)) {
         $badpackages = $dl->___uninstall_package_cache;
         if (isset($badpackages[$memyselfandI]['warnings'])) {
             foreach ($badpackages[$memyselfandI]['warnings'] as $warning) {
                 $dl->log(0, $warning[0]);
             }
         }
         if (isset($badpackages[$memyselfandI]['errors'])) {
             foreach ($badpackages[$memyselfandI]['errors'] as $error) {
                 if (is_array($error)) {
                     $dl->log(0, $error[0]);
                 } else {
                     $dl->log(0, $error->getMessage());
                 }
             }
             if (isset($this->_options['nodeps']) || isset($this->_options['force'])) {
                 return $this->warning('warning: %s should not be uninstalled, other installed packages depend ' . 'on this package');
             }
             return $this->raiseError('%s cannot be uninstalled, other installed packages depend on this package');
         }
         return true;
     }
     // first, list the immediate parents of each package to be uninstalled
     $perpackagelist = array();
     $allparents = array();
     foreach ($params as $i => $param) {
         $a = array('channel' => strtolower($param->getChannel()), 'package' => strtolower($param->getPackage()));
         $deps = $this->_dependencydb->getDependentPackages($a);
         if ($deps) {
             foreach ($deps as $d) {
                 $pardeps = $this->_dependencydb->getDependencies($d);
                 foreach ($pardeps as $dep) {
                     if (strtolower($dep['dep']['channel']) == $a['channel'] && strtolower($dep['dep']['name']) == $a['package']) {
                         if (!isset($perpackagelist[$a['channel'] . '/' . $a['package']])) {
                             $perpackagelist[$a['channel'] . '/' . $a['package']] = array();
                         }
                         $perpackagelist[$a['channel'] . '/' . $a['package']][] = array($d['channel'] . '/' . $d['package'], $dep);
                         if (!isset($allparents[$d['channel'] . '/' . $d['package']])) {
                             $allparents[$d['channel'] . '/' . $d['package']] = array();
                         }
                         if (!isset($allparents[$d['channel'] . '/' . $d['package']][$a['channel'] . '/' . $a['package']])) {
                             $allparents[$d['channel'] . '/' . $d['package']][$a['channel'] . '/' . $a['package']] = array();
                         }
                         $allparents[$d['channel'] . '/' . $d['package']][$a['channel'] . '/' . $a['package']][] = array($d, $dep);
                     }
                 }
             }
         }
     }
     // next, remove any packages from the parents list that are not installed
     $remove = array();
     foreach ($allparents as $parent => $d1) {
         foreach ($d1 as $d) {
             if ($this->_registry->packageExists($d[0][0]['package'], $d[0][0]['channel'])) {
                 continue;
             }
             $remove[$parent] = true;
         }
     }
     // next remove any packages from the parents list that are not passed in for
     // uninstallation
     foreach ($allparents as $parent => $d1) {
         foreach ($d1 as $d) {
             foreach ($params as $param) {
                 if (strtolower($param->getChannel()) == $d[0][0]['channel'] && strtolower($param->getPackage()) == $d[0][0]['package']) {
                     // found it
                     continue 3;
                 }
             }
             $remove[$parent] = true;
         }
     }
     // remove all packages whose dependencies fail
     // save which ones failed for error reporting
     $badchildren = array();
//.........这里部分代码省略.........
开发者ID:upmunspel,项目名称:abiturient,代码行数:101,代码来源:Dependency2.php


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