2017-09-14 101 views
0

我想知道如何覆蓋EasyAdminBundle控制器。實際上,我想從數據庫中編寫一些自定義查詢,我不想使用dqlFilter。我如何覆蓋easyAdminBundle控制器

以下是我的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

查看vendor/javiereguiluz/easyadmin-bundle/Controller/AdminController.php中的listAction() – COil

回答

0

我做這個和它的工作,希望這將是有益的其他人:

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;