通过管理生成器创建新记录时发送电子邮件
-
29-09-2019 - |
题
我曾使用Symfony Admin Generator为运动员管理创建Web应用程序。最后一个客户的要求之一是添加功能以注意用户并在数据库上插入具有相同数字的运动员时向管理员发送电子邮件。到目前为止,运动员桌的列数具有独特的约束,但客户希望运动员可以通过插入。
为此,我试图扩展编辑 /新操作以实现客户需求。
这是代码:
public function executeEdit(sfWebRequest $request)
{
$user = $this->getUser();
if(! $user->hasCredential('admin'))
{
$clube_id = $user->getAttribute('id');
$atleta_id = $request->getParameter('id');
$atleta = Doctrine::getTable('Atleta')->find($atleta_id);
if($clube_id != $atleta->clube_id)
$this->forward404();
}
if($request->get('post'))
{
// check if the inserted athlete BI already exists; if so, display a message to the user and send an email to the system admins
$atleta_id = $request->getParameter('id');
$atletaBIExiste = Doctrine::getTable('Atleta')->findDuplicateAthleteBI($atleta_id);
if($atletaBIExiste)
{
// display a notice message to the user
$this->getUser()->setFlash('error', 'Athlete already exists');
// send an email to the system administrator
}
}
return parent::executeEdit($request);
}
这是我的问题:当我执行编辑操作时,我只想在HTTP发布时检查一个重复的运动员编号,但似乎从来没有。我已经向输出发送了一些例外,以验证哪种类型是HTTP请求,并且似乎总是可以得到的。
解决方案
您将遇到的问题是,当您点击“保存在编辑”页面上时,信息未发布到编辑操作中,则将其发布到称为“更新”的操作中。
查看缓存中的action.class.php文件,您会看到它。
不隶属于 StackOverflow