/** * Set up recommendation modules. * * @param EventInterface $event Event * * @return EventInterface */ public function onSearchConfigured(EventInterface $event) { // Make sure we're triggering in the appropriate context: if ($this->searchId != $event->getParam('runningSearchId')) { return; } $params = $event->getParam('params'); $request = $event->getParam('request'); // Process recommendations for each location: $this->objects = ['top' => [], 'side' => [], 'noresults' => [], 'bottom' => []]; foreach ($this->config as $location => $currentSet) { // If the current location is disabled, skip processing! if (empty($currentSet)) { continue; } // Now loop through all recommendation settings for the location. foreach ((array) $currentSet as $current) { // Break apart the setting into module name and extra parameters: $current = explode(':', $current); $module = array_shift($current); $config = implode(':', $current); if (!$this->pluginManager->has($module)) { throw new \Exception('Could not load recommendation module: ' . $module); } // Build a recommendation module with the provided settings. $obj = $this->pluginManager->get($module); $obj->setConfig($config); $obj->init($params, $request); $this->objects[$location][] = $obj; } } return $event; }
/** * Test expected interface. * * @return void * * @expectedException Zend\ServiceManager\Exception\RuntimeException * @expectedExceptionMessage Plugin ArrayObject does not belong to VuFind\Recommend\RecommendInterface */ public function testExpectedInterface() { $pm = new PluginManager(null); $pm->validatePlugin(new \ArrayObject()); }