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


PHP iMSCP_Events_Aggregator::dispatch方法代碼示例

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


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

示例1: get_file

 /**
  * Load a template file.
  *
  * @throws iMSCP_Exception If template file is not found
  * @param string|array $fname Template file path or an array where the second item contain the template file path
  * @return mixed|string
  */
 public function get_file($fname)
 {
     static $parentTplDir = null;
     if (!is_array($fname)) {
         $this->eventManager->dispatch(iMSCP_Events::onBeforeAssembleTemplateFiles, array('context' => $this, 'templatePath' => $this->root_dir . '/' . $fname));
     } else {
         // INCLUDED file
         $fname = $parentTplDir !== null ? $parentTplDir . '/' . $fname[1] : $fname[1];
     }
     if ($this->is_safe($fname)) {
         $prevParentTplDir = $parentTplDir;
         $parentTplDir = dirname($fname);
         $this->eventManager->dispatch(iMSCP_Events::onBeforeLoadTemplateFile, array('context' => $this, 'templatePath' => $this->root_dir . '/' . $fname));
         ob_start();
         include $this->root_dir . '/' . $fname;
         $fileContent = ob_get_clean();
         $this->eventManager->dispatch(iMSCP_Events::onAfterLoadTemplateFile, array('context' => $this, 'templateContent' => $fileContent));
         $fileContent = preg_replace_callback($this->tpl_include, array($this, 'get_file'), $fileContent);
         $parentTplDir = $prevParentTplDir;
     } else {
         throw new iMSCP_Exception(sprintf('Unable to find the %s template file', $this->root_dir . '/' . $fname));
     }
     $this->eventManager->dispatch(iMSCP_Events::onAfterAssembleTemplateFiles, array('context' => $this, 'templateContent' => $fileContent));
     return $fileContent;
 }
開發者ID:svenjantzen,項目名稱:imscp,代碼行數:32,代碼來源:pTemplate.php

示例2: pluginProtect

 /**
  * Protect the given plugin
  *
  * @param string $name Name of the plugin to protect
  * @return bool self::ACTION_SUCCESS|self::ACTION_FAILURE
  */
 public function pluginProtect($name)
 {
     if ($this->pluginIsEnabled($name) && !$this->pluginIsProtected($name)) {
         $responses = $this->eventsManager->dispatch(iMSCP_Events::onBeforeProtectPlugin, array('pluginManager' => $this, 'pluginName' => $name));
         if (!$responses->isStopped()) {
             $protectedPlugins = $this->protectedPlugins;
             $this->protectedPlugins[] = $name;
             if ($this->pluginUpdateProtectedFile()) {
                 $this->eventsManager->dispatch(iMSCP_Events::onAfterProtectPlugin, array('pluginManager' => $this, 'pluginName' => $name));
                 return self::ACTION_SUCCESS;
             }
             $this->protectedPlugins = $protectedPlugins;
         } else {
             return self::ACTION_STOPPED;
         }
     }
     return self::ACTION_FAILURE;
 }
開發者ID:svenjantzen,項目名稱:imscp,代碼行數:24,代碼來源:Manager.php


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