From a667511e1b11f0a7fbc4bf5a3fe0b0d3877a794b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A9C=C3=A9?= Date: Fri, 24 Nov 2017 00:08:59 +0100 Subject: [PATCH] Add missing part of Embedded list feature --- README.md | 16 ++++++++++++++++ src/Controller/AdminController.php | 25 +++++++++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 src/Controller/AdminController.php diff --git a/README.md b/README.md index f03f984a..1f97d731 100644 --- a/README.md +++ b/README.md @@ -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 -------- diff --git a/src/Controller/AdminController.php b/src/Controller/AdminController.php new file mode 100644 index 00000000..4e23f890 --- /dev/null +++ b/src/Controller/AdminController.php @@ -0,0 +1,25 @@ +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(), + )); + } +}