Skip to content
Snippets Groups Projects
Commit 933fde59 authored by Frank Morgner's avatar Frank Morgner
Browse files

refs #14553 - refactoring munger injection delegator for zf manager v3

* modify entry point of Delegator Factory to new __invoke() method of PSR7 style ContainerInterface
parent bb891d86
No related merge requests found
...@@ -14,12 +14,9 @@ $config = [ ...@@ -14,12 +14,9 @@ $config = [
'VuFind\SessionManager' => 'finc\Session\ManagerFactory', 'VuFind\SessionManager' => 'finc\Session\ManagerFactory',
'VuFind\CookieManager' => 'finc\Service\Factory::getCookieManager' 'VuFind\CookieManager' => 'finc\Service\Factory::getCookieManager'
], ],
'invokables' => [
'mungerinjectionfactory' => 'finc\Service\MungerInjectionFactory'
],
'delegators' => [ 'delegators' => [
'VuFind\Search' => [ 'VuFindSearch\Service' => [
'mungerinjectionfactory' 'finc\Service\MungerInjectionDelegatorFactory'
], ],
], ],
], ],
......
...@@ -30,13 +30,14 @@ ...@@ -30,13 +30,14 @@
*/ */
namespace finc\Service; namespace finc\Service;
use Interop\Container\ContainerInterface;
use VuFindSearch\Query\Query; use VuFindSearch\Query\Query;
use VuFindSearch\Query\QueryGroup; use VuFindSearch\Query\QueryGroup;
use VuFindSearch\Service as SearchService;
use Zend\Config\Config; use Zend\Config\Config;
use Zend\ServiceManager\DelegatorFactoryInterface;
use Zend\ServiceManager\ServiceLocatorInterface;
use Zend\EventManager\EventInterface; use Zend\EventManager\EventInterface;
use VuFindSearch\Service as SearchService; use Zend\ServiceManager\Factory\DelegatorFactoryInterface;
/** /**
* Munger Injection Factory * Munger Injection Factory
...@@ -48,7 +49,7 @@ use VuFindSearch\Service as SearchService; ...@@ -48,7 +49,7 @@ use VuFindSearch\Service as SearchService;
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
* @link https://vufind.org Main Page * @link https://vufind.org Main Page
*/ */
class MungerInjectionFactory implements DelegatorFactoryInterface class MungerInjectionDelegatorFactory implements DelegatorFactoryInterface
{ {
/** /**
* @var SearchService * @var SearchService
...@@ -68,27 +69,29 @@ class MungerInjectionFactory implements DelegatorFactoryInterface ...@@ -68,27 +69,29 @@ class MungerInjectionFactory implements DelegatorFactoryInterface
/** /**
* Creates a delegator of VuFind/Search to register several listeners. * Creates a delegator of VuFind/Search to register several listeners.
* *
* @param ServiceLocatorInterface $serviceLocator * @param ContainerInterface $container
* @param string $name * @param string $name
* @param string $requestedName
* @param callable $callback * @param callable $callback
* @param array|null $options
* *
* @return mixed * @return mixed
*/ */
public function createDelegatorWithName( public function __invoke(
ServiceLocatorInterface $serviceLocator, ContainerInterface $container,
$name, $name,
$requestedName, callable $callback,
$callback array $options = null
) { ) {
$instance = call_user_func($callback); $instance = call_user_func($callback);
$searchConfig = $serviceLocator->get('VuFind\Config')->get('searches');
$searchConfig = $container->get('VuFind\Config')->get('searches');
$e = $instance->getEventManager()->getSharedManager(); $e = $instance->getEventManager()->getSharedManager();
$handlers = $searchConfig->General->escaped_colon_searches; $handlers = $searchConfig->General->escaped_colon_searches;
if (!empty($handlers)) { if (!empty($handlers)) {
$this->searches_to_escape = $handlers->toArray(); $this->searches_to_escape = $handlers->toArray();
$e->attach( $e->attach(
'VuFind\Search', 'VuFindSearch',
'pre', 'pre',
function (EventInterface $event) { function (EventInterface $event) {
$params = $event->getParams(); $params = $event->getParams();
...@@ -104,7 +107,7 @@ class MungerInjectionFactory implements DelegatorFactoryInterface ...@@ -104,7 +107,7 @@ class MungerInjectionFactory implements DelegatorFactoryInterface
} }
if (!empty($shards)) { if (!empty($shards)) {
$this->shards_to_register = $shards; $this->shards_to_register = $shards;
$e->attach('VuFind\Search', 'pre', [$this, 'registerShards']); $e->attach('VuFindSearch', 'pre', [$this, 'registerShards']);
} }
return $instance; return $instance;
} }
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment