当前位置: 首页>>代码示例>>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;未经允许,请勿转载。