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

Added mechanism for passing request object to tab classes.

parent 4b7e79f5
No related merge requests found
...@@ -516,10 +516,12 @@ class AbstractRecord extends AbstractBase ...@@ -516,10 +516,12 @@ class AbstractRecord extends AbstractBase
protected function getAllTabs() protected function getAllTabs()
{ {
if (null === $this->allTabs) { if (null === $this->allTabs) {
$driver = $this->loadRecord();
$cfg = $this->getServiceLocator()->get('Config'); $cfg = $this->getServiceLocator()->get('Config');
$request = $this->getRequest();
$this->allTabs = $this->getServiceLocator() $this->allTabs = $this->getServiceLocator()
->get('VuFind\RecordTabPluginManager') ->get('VuFind\RecordTabPluginManager')
->getTabsForRecord($this->loadRecord(), $cfg['recorddriver_tabs']); ->getTabsForRecord($driver, $cfg['recorddriver_tabs'], $request);
} }
return $this->allTabs; return $this->allTabs;
} }
......
...@@ -45,6 +45,13 @@ abstract class AbstractBase implements TabInterface ...@@ -45,6 +45,13 @@ abstract class AbstractBase implements TabInterface
*/ */
protected $driver = null; protected $driver = null;
/**
* User request associated with the tab (false for none)
*
* @var \Zend\Http\Request|bool
*/
protected $request = false;
/** /**
* Is this tab active? * Is this tab active?
* *
...@@ -82,4 +89,27 @@ abstract class AbstractBase implements TabInterface ...@@ -82,4 +89,27 @@ abstract class AbstractBase implements TabInterface
} }
return $this->driver; return $this->driver;
} }
/**
* Set the user request
*
* @param \Zend\Http\Request $request Request
*
* @return AbstractBase
*/
public function setRequest(\Zend\Http\Request $request)
{
$this->request = $request;
return $this;
}
/**
* Get the user request (or false if unavailable)
*
* @return \Zend\Http\Request|bool
*/
protected function getRequest()
{
return $this->request;
}
} }
\ No newline at end of file
...@@ -81,14 +81,15 @@ class PluginManager extends \VuFind\ServiceManager\AbstractPluginManager ...@@ -81,14 +81,15 @@ class PluginManager extends \VuFind\ServiceManager\AbstractPluginManager
/** /**
* Get an array of valid tabs for the provided record driver. * Get an array of valid tabs for the provided record driver.
* *
* @param \VuFind\RecordDriver\AbstractBase $driver Record driver * @param \VuFind\RecordDriver\AbstractBase $driver Record driver
* @param array $config Tab configuration (map of * @param array $config Tab configuration (map of
* driver class => tab service name * driver class => tab service name
* @param \Zend\Http\Request $request User request (optional)
* *
* @return array service name => tab object * @return array service name => tab object
*/ */
public function getTabsForRecord(\VuFind\RecordDriver\AbstractBase $driver, public function getTabsForRecord(\VuFind\RecordDriver\AbstractBase $driver,
array $config array $config, $request = null
) { ) {
$tabs = array(); $tabs = array();
foreach ($this->getTabServiceNames($driver, $config) as $tabKey => $svc) { foreach ($this->getTabServiceNames($driver, $config) as $tabKey => $svc) {
...@@ -99,6 +100,11 @@ class PluginManager extends \VuFind\ServiceManager\AbstractPluginManager ...@@ -99,6 +100,11 @@ class PluginManager extends \VuFind\ServiceManager\AbstractPluginManager
if (method_exists($newTab, 'setRecordDriver')) { if (method_exists($newTab, 'setRecordDriver')) {
$newTab->setRecordDriver($driver); $newTab->setRecordDriver($driver);
} }
if ($request instanceof \Zend\Http\Request
&& method_exists($newTab, 'setRequest')
) {
$newTab->setRequest($request);
}
if ($newTab->isActive()) { if ($newTab->isActive()) {
$tabs[$tabKey] = $newTab; $tabs[$tabKey] = $newTab;
} }
......
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