我被困在这里了。我正在尝试在Ajax Action中包含一个EventDispatcher,但它只是悄然失败。我是symfony的新手,我目前正致力于定制基于symfony 1.1.6的“VImp”CMS(http://vimp.com/)。
在/apps/xx/modules/xx/actions/base/BaseXxActions.php
中有这样的:
public function executeAjax {
switch($this->getVar('action')) {
case 'something':
sfContext::getInstance()->getEventDispatcher()->notify(
new sfEvent(
$this,
'activity',
array(
'action' => 'user.something.save',
'user' => sfContext::getInstance()->getUser()->getUser(),
'something'=>$something
)
)
);
break;
}
}
现在这只是悄无声息。服务器或symfony日志中没有任何内容。我几乎只是先从几行中复制/粘贴这条线,看起来我使用的参数似乎并不重要。
有人可以帮我吗?我在哪里以及如何获得有关失败原因的具体信息?
谢谢,
托马斯
(我也无法使语法高亮显示起作用......)
答案 0 :(得分:0)
如果有人遇到同样的问题......我终于找到了解决办法:
class frontendConfiguration extends sfApplicationConfiguration
{
public function configure()
{
// Register our listener
$this->dispatcher->connect('user.something.save', array('myClass', 'itsMethod'));
}
}
这告诉事件调度程序在事件被触发时该怎么做。