1

我想知道如何覆盖 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'}]

这是我扩展 BaseAdminController 的 UserController 请让我知道如何从存储库或控制器中自定义查询

namespace EmployeeBundle\Controller;

use JavierEguiluz\Bundle\EasyAdminBundle\Controller\AdminController as BaseAdminController;
use Symfony\Component\HttpFoundation\Request;

class UserController extends BaseAdminController
{
    public function listUserAction()
    {

    }
}
4

1 回答 1

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;
于 2017-09-14T10:32:52.797 回答