diff --git a/module/VuFind/config/module.config.php b/module/VuFind/config/module.config.php index 0108542b49af3d3386763fa2f1747cb76d5a2ee0..83a2b98697a85900d7b94eecbb6bebd488d7dfe5 100644 --- a/module/VuFind/config/module.config.php +++ b/module/VuFind/config/module.config.php @@ -319,6 +319,7 @@ $config = array( ), 'invokables' => array( 'VuFind\SessionManager' => 'Zend\Session\SessionManager', + 'VuFind\Search' => 'VuFindSearch\Service', ), 'initializers' => array( array('VuFind\ServiceManager\Initializer', 'initInstance'), diff --git a/module/VuFind/src/VuFind/Bootstrapper.php b/module/VuFind/src/VuFind/Bootstrapper.php index b9040305d02435c1a8d08d706bda56bbdcbca216..626b5c77022bfe047d8c44f60c6efdf4a1b5a518 100644 --- a/module/VuFind/src/VuFind/Bootstrapper.php +++ b/module/VuFind/src/VuFind/Bootstrapper.php @@ -445,7 +445,7 @@ class Bootstrapper $sm = $this->event->getApplication()->getServiceManager(); $bm = $sm->get('VuFind\Search\BackendManager'); $events = $sm->get('SharedEventManager'); - $events->attach('VuFind\Search', 'resolve', array($bm, 'onResolve')); + $events->attach('VuFindSearch', 'resolve', array($bm, 'onResolve')); } /** diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/View/Helper/Root/CitationTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/View/Helper/Root/CitationTest.php index 58a225635828854d773dfe4ff1c04c9bf708c29b..56424e39f0f42382cd420c09601dbd4f0041f42b 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/View/Helper/Root/CitationTest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/View/Helper/Root/CitationTest.php @@ -276,6 +276,26 @@ class CitationTest extends \VuFindTest\Unit\ViewHelperTestCase // @codingStandardsIgnoreEnd ); + /** + * Setup test case. + * + * Mark test skipped if short_open_tag is not enabled. The partial + * uses short open tags. This directive is PHP_INI_PERDIR, + * i.e. can only be changed via php.ini or a per-directory + * equivalent. The testCitations() will fail if the test is run on + * a system with short_open_tag disabled in the system-wide php + * ini-file. + * + * @return void + */ + protected function setup () + { + parent::setup(); + if (!ini_get('short_open_tag')) { + $this->markTestSkipped('Test requires short_open_tag to be enabled'); + } + } + /** * Test citation generation * diff --git a/module/VuFindSearch/Module.php b/module/VuFindSearch/Module.php index 4847a10d8cbdc64b48a36ff9be08b6555cf6a371..aa9d3122c4d4629a5d47a8334b80e6b6e5a5d19c 100644 --- a/module/VuFindSearch/Module.php +++ b/module/VuFindSearch/Module.php @@ -76,34 +76,4 @@ class Module ), ); } - - /** - * Return service configuration. - * - * @return array - */ - public function getServiceConfig() - { - return array( - 'factories' => array( - 'VuFind\Search' => array($this, 'setup'), - ) - ); - } - - /** - * Return configured search service to superior service manager. - * - * @param ServiceManager $sm Service manager - * - * @return SearchService - */ - public function setup(ServiceManager $sm) - { - $service = new Service(); - if ($sm->has('VuFind\Logger')) { - $service->setLogger($sm->get('VuFind\Logger')); - } - return $service; - } } \ No newline at end of file diff --git a/module/VuFindSearch/src/VuFindSearch/Service.php b/module/VuFindSearch/src/VuFindSearch/Service.php index d8a0b7ecdb74a25ecda6e1af8e5e1332ca7078b3..26d3abaadb4971a08b4924e4b9a23d5ded1e09c3 100644 --- a/module/VuFindSearch/src/VuFindSearch/Service.php +++ b/module/VuFindSearch/src/VuFindSearch/Service.php @@ -33,7 +33,6 @@ use VuFindSearch\Backend\BackendInterface; use VuFindSearch\Feature\RetrieveBatchInterface; use VuFindSearch\Backend\Exception\BackendException; -use Zend\Log\LoggerInterface; use Zend\EventManager\EventManagerInterface; use Zend\EventManager\EventManager; @@ -48,20 +47,22 @@ use Zend\EventManager\EventManager; */ class Service { - /** - * Event manager. + * Event identifiers. * - * @var EventManager + * @var string */ - protected $events; + const EVENT_PRE = 'pre'; + const EVENT_POST = 'post'; + const EVENT_ERROR = 'error'; + const EVENT_RESOLVE = 'resolve'; /** - * Logger, if any. + * Event manager. * - * @var LoggerInterface + * @var EventManager */ - protected $logger; + protected $events; /** * Cache resolved backends. @@ -217,28 +218,17 @@ class Service return $response; } - /** - * Set application logger. - * - * @param LoggerInterface $logger Logger - * - * @return void - */ - public function setLogger(LoggerInterface $logger) - { - $this->logger = $logger; - } - /** * Set EventManager instance. * * @param EventManagerInterface $events Event manager * * @return void + * @todo Deprecate `VuFind\Search' event namespace (2.2) */ public function setEventManager(EventManagerInterface $events) { - $events->setIdentifiers('VuFind\Search'); + $events->setIdentifiers(array('VuFind\Search', 'VuFindSearch')); $this->events = $events; } @@ -252,7 +242,7 @@ class Service public function getEventManager() { if (!$this->events) { - $this->events = new EventManager('VuFind\Search'); + $this->setEventManager(new EventManager()); } return $this->events; } @@ -273,7 +263,7 @@ class Service { if (!isset($this->backends[$backend])) { $response = $this->getEventManager()->trigger( - "resolve", + self::EVENT_RESOLVE, $this, $args, function ($o) { @@ -303,7 +293,7 @@ class Service */ public function triggerError(BackendException $exception, $args) { - $this->getEventManager()->trigger('error', $exception, $args); + $this->getEventManager()->trigger(self::EVENT_ERROR, $exception, $args); } /** @@ -316,7 +306,7 @@ class Service */ protected function triggerPre(BackendInterface $backend, $args) { - $this->getEventManager()->trigger('pre', $backend, $args); + $this->getEventManager()->trigger(self::EVENT_PRE, $backend, $args); } /** @@ -329,22 +319,7 @@ class Service */ protected function triggerPost($response, $args) { - $this->getEventManager()->trigger('post', $response, $args); + $this->getEventManager()->trigger(self::EVENT_POST, $response, $args); } - /** - * Send a message to the logger. - * - * @param string $level Log level - * @param string $message Log message - * @param array $context Log context - * - * @return void - */ - protected function log($level, $message, array $context = array()) - { - if ($this->logger) { - $this->logger->$level($message, $context); - } - } } \ No newline at end of file