本文整理汇总了PHP中Hook::trigger方法的典型用法代码示例。如果您正苦于以下问题:PHP Hook::trigger方法的具体用法?PHP Hook::trigger怎么用?PHP Hook::trigger使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Hook
的用法示例。
在下文中一共展示了Hook::trigger方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: route
public static function route($uri)
{
self::_loadModules();
Hook::trigger(__CLASS__, 'preDispatch', array('uri' => $uri));
$parsed = parse_url($uri);
$parts = explode('/', substr($parsed['path'], 1));
Controller::route($parts);
// $routeName = str_replace('/', '_', substr($parsed['path'], 1));
// print_r($routeName); exit;
//
// print_r($_GET); exit;
switch ($parts[0]) {
case 'page':
self::routePage($parts);
break;
}
}
示例2: startup
$autoloader->init();
/* get instance */
$registry = Registry::getInstance();
$request = Request::getInstance();
$config = Config::getInstance();
/* request and config */
$request->init();
$config->init();
/* database */
Db::construct($config);
Db::init();
/* startup and registry */
startup();
$registry->init();
/* refresh */
$request->refreshSession();
/* detector */
$detectorLanguage = new Detector\Language($registry, $request);
$detectorTemplate = new Detector\Template($registry, $request);
/* set language and template */
$registry->set('language', $detectorLanguage->getOutput());
$registry->set('template', $detectorTemplate->getOutput());
/* language */
$language = Language::getInstance();
$language->init($registry->get('language'));
/* hook */
if ($registry->get('dbStatus') === 2) {
Hook::construct($registry);
Hook::init();
Hook::trigger('init');
}
示例3: renderPage
public function renderPage(Page $page)
{
$rendered = false;
$cacheId = 'page-' . static::$DI['Request']->getRoute();
if (empty($page->nocache)) {
$rendered = static::$DI['Cache\\PageCache']->get($cacheId);
}
if (false === $rendered) {
$content = new \stdClass();
$content->string = '';
try {
if (empty($page->layout)) {
$content = $page->getSegment(0);
$content->string = Hook::trigger(Hook::FILTER, 'renderContent', $content->string, $page->getData());
} else {
$content->string = Hook::trigger(Hook::FILTER, 'renderLayout', $page);
}
} catch (\Exception $e) {
$page->setError($e);
$content->string = Hook::trigger(Hook::FILTER, 'renderLayout', $page);
}
if (empty($page->nocache)) {
static::$DI['Cache\\PageCache']->set($cacheId, $content->string);
}
$rendered = $content->string;
}
$response = new Http\Response($rendered);
$response->setStatus($page->getStatusCode());
$response->setHeader('Content-Type', $page->content_type);
return $response;
}
示例4: header
include_once 'includes/bootstrap.php';
/* get instance */
$registry = Registry::getInstance();
/* redirect to install */
if ($registry->get('dbStatus') < 2 && file_exists('install.php')) {
header('location: install.php');
exit;
}
/* render */
Hook::trigger('renderStart');
if ($registry->get('renderBreak')) {
return;
}
if ($registry->get('routerBreak')) {
$registry->set('contentError', false);
}
if ($registry->get('contentError')) {
header('http/1.0 404 not found');
}
/* template */
$template = Hook::collect('renderTemplate');
if (array_key_exists('header', $template)) {
header($template['header']);
}
if (array_key_exists('content', $template)) {
echo $template['content'];
} else {
include_once 'templates/' . $registry->get('template') . '/index.phtml';
}
Hook::trigger('renderEnd');
示例5: render
/**
* render
*
* @since 3.0.0
*
* @param string $type type of the flash
* @param mixed $message message of the flash
* @param string $title title of the flash
*
* @return string
*/
public function render($type = null, $message = null, $title = null)
{
$output = Hook::trigger('messengerStart');
$outputItem = null;
/* html elements */
if ($title) {
$titleElement = new Html\Element();
$titleElement->init('h2', ['class' => $this->_optionArray['className']['title'] . ' ' . $this->_optionArray['className']['notes'][$type]])->text($title);
}
$boxElement = new Html\Element();
$boxElement->init('div', ['class' => $this->_optionArray['className']['box'] . ' ' . $this->_optionArray['className']['notes'][$type]]);
/* create a list */
if (is_array($message) && count($message) > 1) {
$listElement = new Html\Element();
$listElement->init('ul', ['class' => $this->_optionArray['className']['list']]);
/* collect item output */
foreach ($message as $value) {
$outputItem .= '<li>' . $value . '</li>';
}
$boxElement->html($listElement->html($outputItem));
} else {
$boxElement->html(array_key_exists(0, $message) ? $message[0] : $message);
}
/* collect output */
$output .= $titleElement . $boxElement . $this->_renderAction($type);
$output .= Hook::trigger('messengerEnd');
return $output;
}