本文整理汇总了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;
}
示例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;
}