Skip to content
Snippets Groups Projects
Commit 3becb817 authored by Demian Katz's avatar Demian Katz
Browse files

Made record router smart enough to figure out collection links even if not...

Made record router smart enough to figure out collection links even if not given a full record driver object.
parent d7f77082
No related merge requests found
......@@ -416,6 +416,9 @@ $config = array(
$logger->setConfig(\VuFind\Config\Reader::getConfig());
return $logger;
},
'VuFind\RecordRouter' => function ($sm) {
return new \VuFind\Record\Router($sm->get('VuFind\RecordLoader'));
},
'VuFind\SMS' => 'VuFind\SMS\Factory',
'VuFind\Translator' => function ($sm) {
$factory = new \Zend\I18n\Translator\TranslatorServiceFactory();
......@@ -450,7 +453,6 @@ $config = array(
'VuFind\CacheManager' => 'VuFind\Cache\Manager',
'VuFind\Mailer' => 'VuFind\Mailer',
'VuFind\RecordLoader' => 'VuFind\Record\Loader',
'VuFind\RecordRouter' => 'VuFind\Record\Router',
'VuFind\SearchSpecsReader' => 'VuFind\Config\SearchSpecsReader',
'VuFind\SessionManager' => 'Zend\Session\SessionManager',
'VuFind\WorldCatConnection' => 'VuFind\Connection\WorldCat',
......
......@@ -38,6 +38,23 @@ namespace VuFind\Record;
*/
class Router
{
/**
* Record loader
*
* @var \VuFind\Record\Loader
*/
protected $loader;
/**
* Constructor
*
* @param \VuFind\Record\Loader $loader Record loader
*/
public function __construct(\VuFind\Record\Loader $loader)
{
$this->loader = $loader;
}
/**
* Get routing details for a controller action.
*
......@@ -75,12 +92,13 @@ class Router
if (isset($config->Collections->collections)
&& $config->Collections->collections
) {
if (is_object($driver)
&& true === $driver->tryMethod('isCollection')
) {
if (!is_object($driver)) {
list($source, $id) = explode('|', $driver, 2);
$driver = $this->loader->load($id, $source);
}
if (true === $driver->tryMethod('isCollection')) {
$route['route'] = 'collection';
}
// TODO: make routing work correctly in non-object $driver case
}
}
return $route;
......
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