我想知道如何覆盖EasyAdminBundle控制器。实际上,我想从数据库中编写一些自定义查询,我不想使用dqlFilter。
以下是我的config.yml文件。
easy_admin:
site_name: 'site mame .'
entities:
User:
class: EmployeeBundle\Entity\EmployeeLogin
controller: EmployeeBundle\Controller\UserController
form:
fields: ['id', {property : 'userName', label : 'Users'}, {property: 'status', type:'choice', type_options: {choices: {'Active':'1', 'Deactive':'0'}}}]
new:
title: 'Add Login'
form_options: { validation_groups: ['Default', 'EmployeeLogin'] }
fields: ['-id']
edit:
title: 'Edit Login Details'
form_options: { validation_groups: ['Default'] }
label: 'Employees'
list:
title: "%%entity_label%% customers"
help: 'The list view overrides the global help message'
fields: ['id', {property : 'userName', label : 'Users'}, {property: 'status', type: 'boolean'}, {property : 'lastLogin',format: 'D j-n-Y, h:i:s'}]
这是我的UserController,我扩展了BaseAdminController,请告诉我如何从存储库或控制器中自定义查询
namespace EmployeeBundle\Controller;
use JavierEguiluz\Bundle\EasyAdminBundle\Controller\AdminController as BaseAdminController;
use Symfony\Component\HttpFoundation\Request;
class UserController extends BaseAdminController
{
public function listUserAction()
{
}
}
答案 0 :(得分:1)
我这样做了,希望它对别人有所帮助:
public function createListQueryBuilder($entityClass, $sortDirection, $sortField = null, $dqlFilter = null)
{
$response = parent::createListQueryBuilder('EmployeeLogin, EmployeeMaster', $sortDirection, $sortField, $dqlFilter); // TODO: Change the autogenerated stub
$response->join('entity.userId','emp');
$response->andWhere('emp.lastName = :role')->setParameter('role', 'sagir');
return $response;