Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/logging/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Symfony1 如何在管理生成器中重写processForm()_Symfony1_Symfony 1.4 - Fatal编程技术网

Symfony1 如何在管理生成器中重写processForm()

Symfony1 如何在管理生成器中重写processForm(),symfony1,symfony-1.4,Symfony1,Symfony 1.4,我正试图为任务条令:生成管理员生成的模块中的更新和删除操作添加一些额外的逻辑。我阅读并发现我可以在/application/mymodule/actions/actions.class.php中创建executeUpdate()和executelet()方法。因为executeUpdate()调用processform()方法,所以我认为最好的方法是重写它,而不是executeUpdate(),但不知道如何重写。我需要添加的代码如下: $q = Doctrine_Core::getTable('

我正试图为任务
条令:生成管理员
生成的模块中的
更新
删除
操作添加一些额外的逻辑。我阅读并发现我可以在
/application/mymodule/actions/actions.class.php
中创建
executeUpdate()
executelet()
方法。因为
executeUpdate()
调用
processform()
方法,所以我认为最好的方法是重写它,而不是
executeUpdate()
,但不知道如何重写。我需要添加的代码如下:

$q = Doctrine_Core::getTable('SdrivingEmpresa')
            ->createQuery('a')
            ->where('idempresa = ?', $request->getParameter('idempresa'))
            ->execute();
$file = new sfFilesystem();
$file->remove(sfConfig::get('sf_upload_dir') . '/' . $q[0]->getLogotipo());
我通过复制生成的已编码缓存并写入我的逻辑来为
ExecuteElete()
执行此操作,请参见下文:

public function executeDelete(sfWebRequest $request) {
    $request->checkCSRFProtection();
    $this->dispatcher->notify(new sfEvent($this, 'admin.delete_object', array('object' => $this->getRoute()->getObject())));

    $q = Doctrine_Core::getTable('SdrivingEmpresa')
            ->createQuery('a')
            ->where('idempresa = ?', $request->getParameter('idempresa'))
            ->execute();
    $file = new sfFilesystem();
    $file->remove(sfConfig::get('sf_upload_dir') . '/' . $q[0]->getLogotipo());

    if ($this->getRoute()->getObject()->delete()) {
        $this->getUser()->setFlash('notice', 'The item was deleted successfully.');
    }
    $this->redirect('@sdriving_empresa');
}

但我认为这是不对的,所以我的问题是,我应该对processForm()也这样做,还是有更好的方法来做到这一点?任何建议或帮助?

您可以在管理模块操作中复制在应用程序缓存中生成的
过程表单()
,以覆盖它。

您应该使用模型对象上可用的生命周期事件。您可以添加诸如
preDelete
postDelete
preUpdate
postapdate
preSave
postSave
preInsert
postInsert
。您可以添加任何应该与给定事件关联的逻辑。