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


PHP eZModule::initialize方法代碼示例

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


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

示例1: findModule

 /**
  * Loads a module object by name.
  * The only difference with exists() is that the $module parameter will be
  * assigned the found module.
  *
  * @param string $moduleName The name of the module to find (ex: content)
  * @param mixed $module This parameter will receive the found module object
  * @param array|string
  *        Either an array of path or a single path string. These will be
  *        used as additionnal locations that will be looked into
  * @param boolean $showError
  *        If true an error will be shown if the module it not found.
  * @return eZModule The eZModule object, or null if the module wasn't found
  * @see exists()
  */
 static function findModule($moduleName, $module = null, $pathList = null, $showError = false)
 {
     if ($pathList === null) {
         $pathList = array();
     } else {
         if (!is_array($pathList)) {
             $pathList = array($pathList);
         }
     }
     $searchPathList = eZModule::globalPathList();
     if ($searchPathList === null) {
         $searchPathList = array();
     }
     $searchPathList = array_merge($searchPathList, $pathList);
     $triedList = array();
     $triedDirList = array();
     $foundADir = false;
     foreach ($searchPathList as $path) {
         $dir = "{$path}/{$moduleName}";
         $file = "{$dir}/module.php";
         if (file_exists($file)) {
             if ($module === null) {
                 $module = new eZModule($path, $file, $moduleName, false);
             } else {
                 $module->initialize($path, $file, $moduleName, false);
             }
             return $module;
         } else {
             if (!file_exists($dir)) {
                 $triedDirList[] = $dir;
             } else {
                 $foundADir = true;
                 $triedList[] = $dir;
             }
         }
     }
     $msg = "Could not find module named '{$moduleName}'";
     if ($foundADir) {
         $msg = "\nThese directories had a directory named '{$moduleName}' but did not contain the module.php file:\n" . implode(", ", $triedList) . "\n" . "This usually means it is missing or has a wrong name.";
         if (count($triedDirList) > 0) {
             $msg .= "\n\nThese directories were tried too but none of them exists:\n" . implode(', ', $triedDirList);
         }
     } else {
         if (count($triedDirList) > 0) {
             $msg .= "\nThese directories were tried but none of them exists:\n" . implode(", ", $triedDirList);
         }
     }
     if ($showError) {
         eZDebug::writeWarning($msg);
     }
     return null;
 }
開發者ID:runelangseid,項目名稱:ezpublish,代碼行數:67,代碼來源:ezmodule.php


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