本文整理汇总了PHP中zibo\core\Zibo::triggerEvent方法的典型用法代码示例。如果您正苦于以下问题:PHP Zibo::triggerEvent方法的具体用法?PHP Zibo::triggerEvent怎么用?PHP Zibo::triggerEvent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类zibo\core\Zibo
的用法示例。
在下文中一共展示了Zibo::triggerEvent方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: dispatch
/**
* Dispatches a request to the action of a controller
* @param Request $request The request to dispatch
* @param Response $response The response to dispatch the request to
* @return mixed The return value of the action
* @throws zibo\ZiboException when the action is not invokable
*/
public function dispatch(Request $request, Response $response)
{
$controller = $this->getController($request);
$actionName = $request->getActionName();
$parameters = $request->getParameters();
$callback = $this->processAction($controller, $actionName, $parameters);
$this->prepareController($controller, $request, $response, $actionName, $parameters);
$this->zibo->triggerEvent(self::EVENT_PRE_DISPATCH, $controller, $actionName, $parameters);
$controller->preAction();
$returnValue = $callback->invokeWithArrayArguments($parameters);
$controller->postAction();
$this->zibo->triggerEvent(self::EVENT_POST_DISPATCH, $controller, $actionName, $parameters);
return $returnValue;
}
示例2: Zibo
$zibo = new Zibo($fileBrowser, $configIO);
$zibo->setEnvironment($environment);
$zibo->setDefaultTimeZone('Europe/Brussels');
$zibo->setDefaultLocale(array('en_IE.utf8', 'en_IE', 'en'));
// run Zibo
$zibo->bootModules();
$zibo->main();
} catch (Exception $exception) {
// uncaught exception
$class = get_class($exception);
$message = $exception->getMessage();
$trace = $exception->getTraceAsString();
// try to log the exception
try {
if (isset($zibo)) {
$zibo->triggerEvent(Zibo::EVENT_LOG, $class . ($message ? ': ' . $message : ''), $trace);
}
} catch (Exception $e) {
}
$title = 'Uncaught exception (' . $class . ')' . ($message ? ': ' . $message : '');
if (php_sapi_name() == 'cli') {
echo "\n" . $title . "\n\n" . $trace;
exit;
}
$protocol = isset($_SERVER['SERVER_PROTOCOL']) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0';
header($protocol . ' 500');
echo '<div style="background-color: #fdf5d9; padding: 14px; border: 1px solid #fceec1; -webkit-border-radius: 4px; -moz-border-radius: 4px; border-radius: 4px; color: #404040; text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5);">';
echo '<strong>' . $title . '</strong>';
echo '<pre>' . $trace . '</pre>';
echo '</div>';
}
示例3: testTriggerEventThrowsExceptionWhenSystemEventNameIsPassed
/**
* @expectedException zibo\ZiboException
*/
public function testTriggerEventThrowsExceptionWhenSystemEventNameIsPassed()
{
$zibo = new Zibo($this->getBrowserMock(), $this->getConfigIOMock());
$zibo->triggerEvent(Zibo::EVENT_PRE_ROUTE);
}
示例4: loadConnectionsFromConfig
/**
* Loads the database connections from the Zibo configuration
* @param zibo\core\Zibo $zibo Instance of Zibo
* @return null
* @throws zibo\library\database\exception\DatabaseException when the configuration contains an invalid connection
* @throws zibo\library\database\exception\DatabaseException when the default connection does not exist
*/
private function loadConnectionsFromConfig(Zibo $zibo)
{
$zibo->triggerEvent(Zibo::EVENT_LOG, 'Loading database connections', '', 0, self::LOG_NAME);
$connections = $zibo->getConfigValue(self::CONFIG_CONNECTION, array());
if (!is_array($connections)) {
$connections = array(self::NAME_DEFAULT => $connections);
}
$defaultConnectionName = null;
foreach ($connections as $name => $dsn) {
if ($name == self::NAME_DEFAULT) {
$defaultConnectionName = $name;
}
try {
$dsn = new Dsn($dsn);
$this->registerConnection($name, $dsn);
} catch (DatabaseException $e) {
if ($name == self::NAME_DEFAULT) {
$defaultConnectionName = $dsn;
} else {
throw $e;
}
}
}
if ($defaultConnectionName != null) {
$this->setDefaultConnectionName($defaultConnectionName);
}
}