0
我有一个控制器可以保存一些数据。查看模块异常策略
$pat = $sm->get('Tables\PaymentAttemptsTable');
$pat->save($post);
模块配置具有以下配置:
public function onBootstrap(EventInterface $e)
{
$em = $e->getApplication()->getEventManager();
$em->attach('dispatch', array($this, 'loadConfiguration'), 100);
}
public function loadConfiguration(EventInterface $e)
{
$sm = $e->getApplication()->getServiceManager();
//if this module
$exceptionstrategy = $sm->get('ViewManager')->getExceptionStrategy();
$exceptionstrategy->setExceptionTemplate('error/inserterror');
}
在PaymentAttemptsTable模块CONFI我有一个类似的策略是这样的。
public function onBootstrap(EventInterface $e)
{
$eventManager = $e->getApplication()->getEventManager();
$eventManager->attach('dispatch', array($this, 'loadConfiguration'), 100);
}
public function loadConfiguration(EventInterface $e)
{
$sm = $e->getApplication()->getServiceManager();
//if this module
$exceptionstrategy = $sm->get('ViewManager')->getExceptionStrategy();
$exceptionstrategy->setExceptionTemplate('error/saveerror');
}
在每一个我都有这样的看法confi。
return array(
'view_manager' => array(
'exception_template' => 'error/index',
'template_map' => array(
'error/index' => __DIR__ . '/../view/error/index.phtml',
),
'template_path_stack' => array(
__DIR__ . '/../view',
),
),
);
的事情是,当我在PaymentAttemptsTable类做
throw new SaveError('Table must be a string or instance of TableIdentifier.');
我从控制器获得的模板,并不会形成表类,是有办法解决这一问题?
嗨
例子,我认为这是罚款正常视图模板,但我需要的是一个异常的策略,即当异常平米使用某些模板。 – gastoncs 2013-05-01 22:30:07
啊,我明白了,我很抱歉,我无法帮助你。尽管如果你在try catch块中做了它,你可以在catch中应用模板更改。我知道的不是一个很整洁的方式,但我甚至不确定有内置的方法来实现这一点。 – mic 2013-05-02 07:17:51