From 9ac9a1bc77b866bd0519b126c200c44ce66abd68 Mon Sep 17 00:00:00 2001 From: tacman Date: Mon, 3 Dec 2018 06:23:01 -0500 Subject: [PATCH 1/3] Add Symfony 4 examples Use Dependency Injection instead of the container. --- README.md | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/README.md b/README.md index 211a1cf..8fd102a 100644 --- a/README.md +++ b/README.md @@ -97,6 +97,29 @@ $paginator = $this->container->get('knp_paginator') ->paginate($query, $request->query->get('page', 1), 20); ``` +To run the above examples by injecting the service instead of passing the container (the preferred way in Symfony 4), add the following to the constructor, and replace the $this->container calls with $this->sphinx, $this->em, etc. + +```php +use Javer\SphinxBundle\Sphinx\Manager; +use Knp\Component\Pager\Pagination\PaginationInterface; +use Doctrine\ORM\EntityManagerInterface; + + public function __construct(EntityManagerInterface $em, + PaginatorInterface $paginator, + Manager $sphinx) + + private $sphinx; + private $em; + private $paginator; + + { + $this->sphinx = $sphinx; + $this->em = $em; + $this->paginator = $paginator; + } + +``` + Sample shpinx.conf for the given example above: ``` source product From cf6421db16b1398d210cadcef9c98299a89ddc92 Mon Sep 17 00:00:00 2001 From: tacman Date: Mon, 3 Dec 2018 08:44:25 -0500 Subject: [PATCH 2/3] back-tick code references --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 8fd102a..ce1784b 100644 --- a/README.md +++ b/README.md @@ -97,7 +97,7 @@ $paginator = $this->container->get('knp_paginator') ->paginate($query, $request->query->get('page', 1), 20); ``` -To run the above examples by injecting the service instead of passing the container (the preferred way in Symfony 4), add the following to the constructor, and replace the $this->container calls with $this->sphinx, $this->em, etc. +To run the above examples by injecting the service instead of passing the container (the preferred way in Symfony 4), add the following to the constructor, and replace the `$this->container` calls with `$this->sphinx`, `$this->em`, etc. ```php use Javer\SphinxBundle\Sphinx\Manager; From 52244dbdee2196c352bed1612756e35160ea999d Mon Sep 17 00:00:00 2001 From: tacman Date: Mon, 3 Dec 2018 11:32:28 -0500 Subject: [PATCH 3/3] Move use statements --- README.md | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index ce1784b..0da547c 100644 --- a/README.md +++ b/README.md @@ -104,14 +104,15 @@ use Javer\SphinxBundle\Sphinx\Manager; use Knp\Component\Pager\Pagination\PaginationInterface; use Doctrine\ORM\EntityManagerInterface; - public function __construct(EntityManagerInterface $em, +private $sphinx; +private $em; +private $paginator; + + +public function __construct(EntityManagerInterface $em, PaginatorInterface $paginator, Manager $sphinx) - private $sphinx; - private $em; - private $paginator; - { $this->sphinx = $sphinx; $this->em = $em;