如何将一些代码应用于管理员列表视图中显示的每个实体?
例如,如果我有一个TagManager
并且需要为每个显示的实体加载标签,我该怎么做?是否有一种方法可以在实体的管理中覆盖,或者我可以绑定到某些列表表单事件吗?我找不到地方可以做到这一点。
我不想绑定到实体onLoad
event.
EDIT:在您的entityAdminController中:
public function listAction()
{
if (false === $this->admin->isGranted('LIST')) {
throw new AccessDeniedException();
}
$datagrid = $this->admin->getDatagrid();
$formView = $datagrid->getForm()->createView();
foreach($datagrid->getResults() as $object)
{
//do what you want with $object
}
// set the theme for the current Admin Form
$this->get('twig')->getExtension('form')->renderer->setTheme($formView, $this->admin->getFilterTheme());
return $this->render($this->admin->getTemplate('list'), array(
'action' => 'list',
'form' => $formView,
'datagrid' => $datagrid
));
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)