Skip to content

Commit

Permalink
Add missing part of Embedded list feature
Browse files Browse the repository at this point in the history
  • Loading branch information
alterphp committed Nov 23, 2017
1 parent 593b8c7 commit a667511
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,22 @@ class AppKernel extends Kernel
}
```

### Step 3: Replace EasyAdmin controller

Instead of loading routes from EasyAdminBundle AdminController, load them from __EasyAdminExtensionBundle__ AdminController.

```yaml
# app/config/routing.yml
easy_admin_bundle:
resource: "@EasyAdminExtensionBundle/Controller/AdminController.php"
type: annotation
prefix: /admin

# ...
```

If you have defined your own admin controllers, make them extend EasyAdminExtensionBundle admin controller.

Features
--------

Expand Down
25 changes: 25 additions & 0 deletions src/Controller/AdminController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

namespace AlterPHP\EasyAdminExtensionBundle\Controller;

use EasyCorp\Bundle\EasyAdminBundle\Controller\AdminController as BaseAdminController;
use EasyCorp\Bundle\EasyAdminBundle\Event\EasyAdminEvents;

class AdminController extends BaseAdminController
{
protected function embeddedListAction()
{
$this->dispatch(EasyAdminEvents::PRE_LIST);

$fields = $this->entity['list']['fields'];
$paginator = $this->findAll($this->entity['class'], $this->request->query->get('page', 1), $this->config['list']['max_results'], $this->request->query->get('sortField'), $this->request->query->get('sortDirection'));

$this->dispatch(EasyAdminEvents::POST_LIST, array('paginator' => $paginator));

return $this->render('EasyAdminExtensionBundle:default:embedded_list.html.twig', array(
'paginator' => $paginator,
'fields' => $fields,
'masterRequest' => $this->get('request_stack')->getMasterRequest(),
));
}
}

0 comments on commit a667511

Please sign in to comment.