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

Replaced ugly __call() methods with route configuration to achieve the same...

Replaced ugly __call() methods with route configuration to achieve the same legacy compatibility effect.
parent 4ef735b2
No related merge requests found
...@@ -27,6 +27,26 @@ $config = array( ...@@ -27,6 +27,26 @@ $config = array(
'action' => 'Show', 'action' => 'Show',
) )
) )
),
'legacy-summonrecord' => array(
'type' => 'Zend\Mvc\Router\Http\Literal',
'options' => array(
'route' => '/Summon/Record',
'defaults' => array(
'controller' => 'SummonRecord',
'action' => 'Home',
)
)
),
'legacy-worldcatrecord' => array(
'type' => 'Zend\Mvc\Router\Http\Literal',
'options' => array(
'route' => '/WorldCat/Record',
'defaults' => array(
'controller' => 'WorldcatRecord',
'action' => 'Home',
)
)
) )
), ),
), ),
......
...@@ -477,11 +477,14 @@ class AbstractRecord extends AbstractBase ...@@ -477,11 +477,14 @@ class AbstractRecord extends AbstractBase
*/ */
protected function loadRecord() protected function loadRecord()
{ {
// Only load the record if it has not already been loaded: // Only load the record if it has not already been loaded. Note that
// when determining record ID, we check both the route match (the most
// common scenario) and the GET parameters (a fallback used by some
// legacy routes).
if (!is_object($this->driver)) { if (!is_object($this->driver)) {
$this->driver = call_user_func( $this->driver = call_user_func(
array($this->searchObject, 'getRecord'), array($this->searchObject, 'getRecord'),
$this->params()->fromRoute('id') $this->params()->fromRoute('id', $this->params()->fromQuery('id'))
); );
} }
return $this->driver; return $this->driver;
......
...@@ -96,29 +96,6 @@ class SummonController extends AbstractSearch ...@@ -96,29 +96,6 @@ class SummonController extends AbstractSearch
return $this->resultsAction(); return $this->resultsAction();
} }
/**
* Forward unrecognized actions to record controller for legacy URL
* compatibility.
*
* @param string $method Method name being called.
* @param array $params Parameters passed to method.
*
* @return void
*/
public function __call($method, $params)
{
if (substr($method, -6) == 'Action') {
$action = substr($method, 0, strlen($method) - 6);
// Special case for default record action:
if ($action == 'record') {
$action = 'home';
}
return $this->forward()
->dispatch('SummonRecord', array('action' => $action));
}
return parent::__call($method, $params);
}
/** /**
* Return a Search Results object containing advanced facet information. This * Return a Search Results object containing advanced facet information. This
* data may come from the cache, and it is currently shared between the Home * data may come from the cache, and it is currently shared between the Home
......
...@@ -68,28 +68,5 @@ class WorldcatController extends AbstractSearch ...@@ -68,28 +68,5 @@ class WorldcatController extends AbstractSearch
{ {
return $this->resultsAction(); return $this->resultsAction();
} }
/**
* Forward unrecognized actions to record controller for legacy URL
* compatibility.
*
* @param string $method Method name being called.
* @param array $params Parameters passed to method.
*
* @return void
*/
public function __call($method, $params)
{
if (substr($method, -6) == 'Action') {
$action = substr($method, 0, strlen($method) - 6);
// Special case for default record action:
if ($action == 'record') {
$action = 'home';
}
return $this->forward()
->dispatch('WorldcatRecord', array('action' => $action));
}
return parent::__call($method, $params);
}
} }
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