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


PHP ExtensionManager::findService方法代碼示例

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


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

示例1: makeInstanceService

 /**
  * Find the best service and check if it works.
  * Returns object of the service class.
  *
  * @param string $serviceType Type of service (service key).
  * @param string $serviceSubType Sub type like file extensions or similar. Defined by the service.
  * @param mixed $excludeServiceKeys List of service keys which should be excluded in the search for a service. Array or comma list.
  * @return object The service object or an array with error info's.
  */
 public static function makeInstanceService($serviceType, $serviceSubType = '', $excludeServiceKeys = array())
 {
     $error = FALSE;
     if (!is_array($excludeServiceKeys)) {
         $excludeServiceKeys = self::trimExplode(',', $excludeServiceKeys, 1);
     }
     $requestInfo = array('requestedServiceType' => $serviceType, 'requestedServiceSubType' => $serviceSubType, 'requestedExcludeServiceKeys' => $excludeServiceKeys);
     while ($info = \TYPO3\CMS\Core\Extension\ExtensionManager::findService($serviceType, $serviceSubType, $excludeServiceKeys)) {
         // provide information about requested service to service object
         $info = array_merge($info, $requestInfo);
         // Check persistent object and if found, call directly and exit.
         if (is_object($GLOBALS['T3_VAR']['makeInstanceService'][$info['className']])) {
             // update request info in persistent object
             $GLOBALS['T3_VAR']['makeInstanceService'][$info['className']]->info = $info;
             // reset service and return object
             $GLOBALS['T3_VAR']['makeInstanceService'][$info['className']]->reset();
             return $GLOBALS['T3_VAR']['makeInstanceService'][$info['className']];
         } else {
             $requireFile = self::getFileAbsFileName($info['classFile']);
             if (@is_file($requireFile)) {
                 self::requireOnce($requireFile);
                 $obj = self::makeInstance($info['className']);
                 if (is_object($obj)) {
                     if (!@is_callable(array($obj, 'init'))) {
                         // use silent logging??? I don't think so.
                         die('Broken service:' . \TYPO3\CMS\Core\Utility\DebugUtility::viewArray($info));
                     }
                     $obj->info = $info;
                     // service available?
                     if ($obj->init()) {
                         // create persistent object
                         $GLOBALS['T3_VAR']['makeInstanceService'][$info['className']] = $obj;
                         // needed to delete temp files
                         register_shutdown_function(array(&$obj, '__destruct'));
                         return $obj;
                     }
                     $error = $obj->getLastErrorArray();
                     unset($obj);
                 }
             }
         }
         // deactivate the service
         \TYPO3\CMS\Core\Extension\ExtensionManager::deactivateService($info['serviceType'], $info['serviceKey']);
     }
     return $error;
 }
開發者ID:noxludo,項目名稱:TYPO3v4-Core,代碼行數:55,代碼來源:GeneralUtility.php


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