本文整理汇总了PHP中EventUtil::dispatch方法的典型用法代码示例。如果您正苦于以下问题:PHP EventUtil::dispatch方法的具体用法?PHP EventUtil::dispatch怎么用?PHP EventUtil::dispatch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EventUtil
的用法示例。
在下文中一共展示了EventUtil::dispatch方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: stopQuery
public function stopQuery()
{
$query = $this->currentQuery;
$query['time'] = microtime(true) - $this->start;
$zevent = new GenericEvent(null, $query);
\EventUtil::dispatch('log.sql', $zevent);
}
示例2: validatePostProcess
/**
* Post-Process the basic object validation with class specific logic.
*
* Subclasses can define appropriate implementations.
*
* @param string $type Controller type.
* @param array $data Data to be used for validation.
*
* @return boolean
*/
public function validatePostProcess($type = 'user', $data = null)
{
EventUtil::dispatch('dbobject.validatepostprocess', new \Zikula\Core\Event\GenericEvent($this));
return true;
}
示例3: unregisterSubscriberBundles
/**
* Unregister all subscribers from the system.
*
* This cascades to remove all event handlers, sorting data and update bindings table.
*
* @param array $bundles Module's bundles object.
*
* @return void
*/
public static function unregisterSubscriberBundles(array $bundles)
{
$hookManager = ServiceUtil::getManager()->get('hook_dispatcher');
foreach ($bundles as $bundle) {
$hookManager->unregisterSubscriberBundle($bundle);
$event = new \Zikula\Core\Event\GenericEvent($bundle, array('areaid' => $hookManager->getAreaId($bundle->getArea())));
EventUtil::dispatch('installer.subscriberbundle.uninstalled', $event);
}
}
示例4: _getThemeFilterEvent
/**
* Filter results for a given getTheme() type.
*
* @param string $themeName Theme name.
* @param string $type Event type.
*
* @return string Theme name
*/
private static function _getThemeFilterEvent($themeName, $type)
{
$event = new GenericEvent(null, array('type' => $type), $themeName);
return EventUtil::dispatch('user.gettheme', $event)->getData();
}
示例5: postStmtExecute
/**
* Executed following a Doctrine statement exec query.
*
* @param Doctrine_Event $event The Doctrine event instance.
*
* @return void
*/
public function postStmtExecute(Doctrine_Event $event)
{
$event->end();
$zevent = new GenericEvent(null, array('time' => $event->getElapsedSecs(), 'query' => $event->getQuery()));
EventUtil::dispatch('log.sql', $zevent);
}
示例6: moduleServicesAction
/**
* @Route("/moduleservices/{moduleName}", options={"zkNoBundlePrefix" = 1})
* @Method("GET")
*
* Display services available to the module
*
* @param $moduleName
* @internal param GenericEvent $event
* @throws AccessDeniedException Thrown if the user doesn't have admin permissions over the module
*
* @return Response
*/
public function moduleServicesAction($moduleName)
{
if (!SecurityUtil::checkPermission($moduleName . '::', '::', ACCESS_ADMIN)) {
throw new AccessDeniedException();
}
// notify EVENT here to gather any system service links
$event = new GenericEvent(null, array('modname' => $moduleName));
\EventUtil::dispatch('module_dispatch.service_links', $event);
$sublinks = $event->getData();
$this->view->assign('sublinks', $sublinks);
$this->view->assign('currentmodule', $moduleName);
return new Response($this->view->fetch('Admin/HookUi/moduleservices.tpl'));
}
示例7: getClass
/**
* Get module class.
*
* @param string $modname Module name.
* @param string $type Type.
* @param boolean $api Whether or not to get the api class.
* @param boolean $force Whether or not to force load.
*
* @return boolean|string Class name.
*/
public static function getClass($modname, $type, $api = false, $force = false)
{
// do not cache this process - drak
if ($api) {
$result = self::loadApi($modname, $type);
} else {
$result = self::load($modname, $type);
}
if (!$result) {
return false;
}
$modinfo = self::getInfo(self::getIDFromName($modname));
$className = $api ? ucwords($modname) . '\\Api\\' . ucwords($type) . 'Api' : ucwords($modname) . '\\Controller\\' . ucwords($type) . 'Controller';
// allow overriding the OO class (to override existing methods using inheritance).
$event = new GenericEvent(null, array('modname', 'modinfo' => $modinfo, 'type' => $type, 'api' => $api), $className);
EventUtil::dispatch('module_dispatch.custom_classname', $event);
if ($event->isPropagationStopped()) {
$className = $event->getData();
}
// check the modules state
if (!$force && !self::available($modname)) {
return false;
}
if (class_exists($className)) {
return $className;
}
return false;
}
示例8: formatForDisplayHTML
/**
* Format a variable for HTML display. This method is recursive array safe.
*
* @param string $var The variable to format.
*
* @return string The formatted variable.
*/
public static function formatForDisplayHTML($var)
{
// This search and replace finds the text 'x@y' and replaces
// it with HTML entities, this provides protection against
// email harvesters
//
// Note that the use of \024 and \022 are needed to ensure that
// this does not break HTML tags that might be around either
// the username or the domain name
static $search = array('/([^\\024])@([^\\022])/se');
static $replace = array('"&#" .
sprintf("%03d", ord("\\1")) .
";@&#" .
sprintf("%03d", ord("\\2")) . ";";');
static $allowedtags = null;
static $outputfilter;
static $event;
if (!$event) {
$event = new GenericEvent();
}
if (!isset($allowedtags)) {
$allowedHTML = array();
$allowableHTML = System::getVar('AllowableHTML');
if (is_array($allowableHTML)) {
foreach ($allowableHTML as $k => $v) {
if ($k == '!--') {
if ($v != 0) {
$allowedHTML[] = "{$k}.*?--";
}
} else {
switch ($v) {
case 0:
break;
case 1:
$allowedHTML[] = "/?{$k}\\s*/?";
break;
case 2:
$allowedHTML[] = "/?\\s*{$k}" . "(\\s+[\\w:]+\\s*=\\s*(\"[^\"]*\"|'[^']*'))*" . '\\s*/?';
break;
}
}
}
}
if (count($allowedHTML) > 0) {
$allowedtags = '~<\\s*(' . implode('|', $allowedHTML) . ')\\s*>~is';
} else {
$allowedtags = '';
}
}
if (!isset($outputfilter)) {
if (ModUtil::available('SecurityCenterModule') && !System::isInstalling()) {
$outputfilter = System::getVar('outputfilter');
} else {
$outputfilter = 0;
}
}
if (is_array($var)) {
foreach ($var as $k => $v) {
$var[$k] = self::formatForDisplayHTML($v);
}
} else {
// Run additional filters
if ($outputfilter > 0) {
$event->setData($var)->setArgument('filter', $outputfilter);
$var = EventUtil::dispatch('system.outputfilter', $event)->getData();
}
// Preparse var to mark the HTML that we want
if (!empty($allowedtags)) {
$var = preg_replace($allowedtags, "\\1", $var);
}
// Encode email addresses
$var = preg_replace($search, $replace, $var);
// Fix html entities
$var = htmlspecialchars($var);
// Fix the HTML that we want
$var = preg_replace_callback('#\\022([^\\024]*)\\024#', create_function('$m', 'return DataUtil::formatForDisplayHTML_callback($m);'), $var);
// Fix entities if required
if (System::getVar('htmlentities')) {
$var = preg_replace('/&([a-z#0-9]+);/i', "&\\1;", $var);
}
}
return $var;
}
示例9: formatForDisplayHTML
/**
* Format a variable for HTML display. This method is recursive array safe.
*
* @param string $var The variable to format.
*
* @return string The formatted variable.
*/
public static function formatForDisplayHTML($var)
{
static $allowedtags = null;
static $outputfilter;
static $event;
if (!$event) {
$event = new \Zikula\Core\Event\GenericEvent();
}
if (!isset($allowedtags)) {
$allowedHTML = array();
$allowableHTML = System::getVar('AllowableHTML');
if (is_array($allowableHTML)) {
foreach ($allowableHTML as $k => $v) {
if ($k == '!--') {
if ($v != 0) {
$allowedHTML[] = "{$k}.*?--";
}
} else {
switch ($v) {
case 0:
break;
case 1:
$allowedHTML[] = "/?{$k}\\s*/?";
break;
case 2:
$allowedHTML[] = "/?\\s*{$k}" . "(\\s+[\\w:]+\\s*=\\s*(\"[^\"]*\"|'[^']*'))*" . '\\s*/?';
break;
}
}
}
}
if (count($allowedHTML) > 0) {
$allowedtags = '~<\\s*(' . implode('|', $allowedHTML) . ')\\s*>~is';
} else {
$allowedtags = '';
}
}
if (!isset($outputfilter)) {
if (ModUtil::available('ZikulaSecurityCenterModule') && !System::isInstalling()) {
$outputfilter = System::getVar('outputfilter', 0);
} else {
$outputfilter = 0;
}
}
if (is_array($var)) {
foreach ($var as $k => $v) {
$var[$k] = self::formatForDisplayHTML($v);
}
} else {
// Run additional filters
if ($outputfilter > 0) {
$event->setData($var)->setArg('filter', $outputfilter);
$var = EventUtil::dispatch('system.outputfilter', $event)->getData();
}
// Preparse var to mark the HTML that we want
if (!empty($allowedtags)) {
$var = preg_replace($allowedtags, "\\1", $var);
}
// Fix html entities
$var = htmlspecialchars($var);
// Fix the HTML that we want
$var = preg_replace_callback('#\\022([^\\024]*)\\024#', create_function('$m', 'return DataUtil::formatForDisplayHTML_callback($m);'), $var);
// Fix entities if required
if (System::getVar('htmlentities')) {
$var = preg_replace('/&([a-z#0-9]+);/i', "&\\1;", $var);
}
}
return $var;
}