我在索納塔很新。我有一個涉及客戶和貸款的項目。在ClientsAdmin.php我已配置configureRoutes和getPersistentParameters功能索納塔管理套件configureRoutes getPersistentParameters
protected function configureRoutes(RouteCollection $collection)
{
$collection->add('transacciones','transacciones/{id}');
}
public function getPersistentParameters()
{
if (!$this->getRequest()) {
return array();
}
return array(
'id' => $this->getRequest()->get('id'),
);
}
而且,我必須重寫CRUDController(和service.yml)
//service.yml
financiera.admin.clientes:
class: BitsMkt\FinancieraBundle\Admin\ClientesAdmin
arguments: [ ~,BitsMkt\FinancieraBundle\Entity\Clientes,FinancieraBundle:ClientesCRUD]
tags:
- {name: sonata.admin, manager_type: orm, group: Sistema, label: Clientes}
//ClientesCRUDController.php
namespace Bitsmkt\FinancieraBundle\Controller;
use Sonata\AdminBundle\Controller\CRUDController;
class ClientesCRUDController extends CRUDController
{
public function transaccionesAction($id = null)
{
//throw new \RuntimeException('The Request object has not been set ' . $id);
if (false === $this->admin->isGranted('LIST')) {
throw new AccessDeniedException();
}
$id = $this->get('request')->get($this->admin->getIdParameter());
if ($id == '*') {
# TODOS - Viene de Dashboard
}else
{
$object = $this->admin->getObject($id);
if (!$object) {
throw new NotFoundHttpException(sprintf('unable to find the object with id : %s', $id));
}
$this->admin->setSubject($object);
}
$datagrid = $this->admin->getDatagrid();
$formView = $datagrid->getForm()->createView();
// set the theme for the current Admin Form
$this->get('twig')->getExtension('form')->renderer->setTheme($formView, $this->admin->getFilterTheme());
return $this->render('FinancieraBundle:Frontend:prestamos_clientes.html.twig', array(
'action' => 'list',
'form' => $formView,
'datagrid' => $datagrid,
'csrf_token' => $this->getCsrfToken('sonata.batch'),
));
}
}
的prestamos_clientes.html.twig視圖,示出了客戶端和貸款信息。
問題: 我想用$ id參數過濾創建的列表視圖(transaccionesAction)並查看特定客戶端的貸款。
謝謝。
爲什麼不創建貸款實體和'configuredatagridfilter管理員()'添加客戶端列表 –