本文整理汇总了PHP中Zend\EventManager\EventInterface::setError方法的典型用法代码示例。如果您正苦于以下问题:PHP EventInterface::setError方法的具体用法?PHP EventInterface::setError怎么用?PHP EventInterface::setError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend\EventManager\EventInterface
的用法示例。
在下文中一共展示了EventInterface::setError方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: onRoute
/**
* @internal
*/
public function onRoute(\Zend\EventManager\EventInterface $e)
{
// Validate loglevel value. Invalid content will cause the route to fail
// and trigger the usage message.
if (!preg_match('/^(emerg|alert|crit|err|warn|notice|info|debug)?$/', $e->getRouteMatch()->getParam('loglevel'))) {
$e->setError(\Zend\Mvc\Application::ERROR_ROUTER_NO_MATCH);
$e->getTarget()->getEventManager()->trigger(\Zend\Mvc\MvcEvent::EVENT_DISPATCH_ERROR, $e);
}
}
示例2: onRoute
/**
* @internal
*/
public function onRoute(\Zend\EventManager\EventInterface $e)
{
// Validate loglevel value. Invalid content will cause the route to fail
// and trigger the usage message.
$logLevel = $e->getRouteMatch()->getParam('loglevel');
if ($logLevel != '' and !\Zend\Validator\StaticValidator::execute($logLevel, 'Library\\LogLevel')) {
$e->setError(\Zend\Mvc\Application::ERROR_ROUTER_NO_MATCH);
$e->setName(\Zend\Mvc\MvcEvent::EVENT_DISPATCH_ERROR);
$e->getTarget()->getEventManager()->triggerEvent($e);
}
}
示例3: flush
public static function flush(EventInterface $e)
{
try {
if ($e->getTarget() instanceof EntityManager) {
$em = $e->getTarget();
} elseif ($e instanceof MvcEvent) {
$em = $e->getApplication()->getServiceManager()->get('EntityManager');
} else {
throw new Exception\RuntimeException('No EntityManager instance available');
}
if (null !== $e->getParam('entity')) {
$em->flush($e->getParam('entity'));
} else {
$em->flush();
}
} catch (\Exception $ex) {
if (!$e instanceof MvcEvent) {
throw $ex;
}
$e->setError(self::ERROR_FLUSH)->setParam('exception', $ex);
$e->getApplication()->getEventManager()->trigger(MvcEvent::EVENT_DISPATCH_ERROR, $e);
}
}