當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Tiki_Profile::getRequiredProfiles方法代碼示例

本文整理匯總了PHP中Tiki_Profile::getRequiredProfiles方法的典型用法代碼示例。如果您正苦於以下問題:PHP Tiki_Profile::getRequiredProfiles方法的具體用法?PHP Tiki_Profile::getRequiredProfiles怎麽用?PHP Tiki_Profile::getRequiredProfiles使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Tiki_Profile的用法示例。


在下文中一共展示了Tiki_Profile::getRequiredProfiles方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: getInstallOrder

 function getInstallOrder(Tiki_Profile $profile)
 {
     if ($profile == null) {
         return false;
     }
     // Obtain the list of all required profiles
     $dependencies = $profile->getRequiredProfiles(true);
     $dependencies[$profile->getProfileKey()] = $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 $key => $prf) {
         if (empty($prf)) {
             throw new Exception("Unknown objects are referenced: " . $key);
         }
         $short[$key] = array();
         foreach ($prf->getRequiredProfiles() as $k => $p) {
             $short[$key][] = $k;
         }
         foreach ($prf->getNamedObjects() as $o) {
             $knownObjects[] = Tiki_Profile_Object::serializeNamedObject($o);
         }
         foreach ($prf->getReferences() as $o) {
             $referenced[] = Tiki_Profile_Object::serializeNamedObject($o);
         }
         if (!$this->isInstallable($prf)) {
             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 $key => $prf) {
         if (!$this->isInstalled($prf, $key == $profile->getProfileKey() || $this->prefixDependencies)) {
             $toSequence[] = $key;
         }
     }
     // 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));
         }
         $key = reset($toSequence);
         // Remove packages that are already scheduled or installed from dependencies
         $short[$key] = array_diff($short[$key], array_keys($this->installed), $toInstall);
         $element = array_shift($toSequence);
         if (count($short[$key])) {
             $toSequence[] = $element;
         } else {
             $counter = 0;
             $toInstall[] = $element;
         }
     }
     $final = array();
     // Perform the actual install
     foreach ($toInstall as $key) {
         $final[] = $dependencies[$key];
     }
     return $final;
 }
開發者ID:linuxwhy,項目名稱:tiki-1,代碼行數:72,代碼來源:Installer.php


注:本文中的Tiki_Profile::getRequiredProfiles方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。