【发布时间】:2017-09-21 10:56:20
【问题描述】:
请问,我如何使用 Sf3 + SonataAdminBundle 和 Knp Trabnslatable 行为作为翻译策略克隆具有可翻译字段内容的对象。
我已经创建了一个自定义操作来克隆我的对象,所有不可翻译的字段都被克隆并正确插入,可翻译的除外。
//Custom action to clone the object
public function cloneAction($id){
$object = $this->admin->getSubject();
if( !$object && !is_object( $object ))
{
throw new NotFoundHttpException( 'Enable to find the object with the id : '. $id );
}
$clonedObject = clone $object;
$ret = $this->admin->create( $clonedObject );
$clonedObject->translate()->setTitle( $object->translate()->getTitle(). ' (Cloned)' );
$this->addFlash( 'sonata_flash_success', 'Cloned successfully' );
return new RedirectResponse( $this->admin->generateUrl('list') );
}
【问题讨论】:
标签: symfony doctrine-orm sonata-admin sonata