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


PHP Tiki_Profile::getReferences方法代码示例

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


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

示例1: getInstallOrder

 function getInstallOrder(Tiki_Profile $profile)
 {
     // Obtain the list of all required profiles
     $dependencies = $profile->getRequiredProfiles(true);
     $dependencies[$profile->url] = $profile;
     $referenced = array();
     $knownObjects = array();
     foreach (Tiki_Profile_Object::getNamedObjects() as $o) {
         $knownObjects[] = Tiki_Profile_Object::serializeNamedObject($o);
     }
     // Build the list of dependencies for each profile
     $short = array();
     foreach ($dependencies as $url => $profile) {
         $short[$url] = array();
         foreach ($profile->getRequiredProfiles() as $u => $p) {
             $short[$url][] = $u;
         }
         foreach ($profile->getNamedObjects() as $o) {
             $knownObjects[] = Tiki_Profile_Object::serializeNamedObject($o);
         }
         foreach ($profile->getReferences() as $o) {
             $referenced[] = Tiki_Profile_Object::serializeNamedObject($o);
         }
         if (!$this->isInstallable($profile)) {
             return false;
         }
     }
     // Make sure all referenced objects actually exist
     $remain = array_diff($referenced, $knownObjects);
     if (!empty($remain)) {
         throw new Exception("Unknown objects are referenced: " . implode(', ', $remain));
     }
     // Build the list of packages that need to be installed
     $toSequence = array();
     foreach ($dependencies as $url => $profile) {
         if (!$this->isInstalled($profile)) {
             $toSequence[] = $url;
         }
     }
     // Order the packages to make sure all dependencies are met
     $toInstall = array();
     $counter = 0;
     while (count($toSequence)) {
         // If all packages were tested and no order was found, exit
         // Probably means there is a circular dependency
         if ($counter++ > count($toSequence) * 2) {
             throw new Exception("Profiles could not be ordered: " . implode(", ", $toSequence));
         }
         $url = reset($toSequence);
         // Remove packages that are already scheduled or installed from dependencies
         $short[$url] = array_diff($short[$url], array_keys($this->installed), $toInstall);
         $element = array_shift($toSequence);
         if (count($short[$url])) {
             $toSequence[] = $element;
         } else {
             $counter = 0;
             $toInstall[] = $element;
         }
     }
     $final = array();
     // Perform the actual install
     foreach ($toInstall as $url) {
         $final[] = $dependencies[$url];
     }
     return $final;
 }
开发者ID:Kraiany,项目名称:kraiany_site_docker,代码行数:66,代码来源:installlib.php


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