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