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

Simplified use of theme resource container by making it a service.

parent 4e24213c
No related merge requests found
...@@ -494,6 +494,7 @@ $config = array( ...@@ -494,6 +494,7 @@ $config = array(
'VuFind\SearchSpecsReader' => 'VuFind\Config\SearchSpecsReader', 'VuFind\SearchSpecsReader' => 'VuFind\Config\SearchSpecsReader',
'VuFind\SessionManager' => 'Zend\Session\SessionManager', 'VuFind\SessionManager' => 'Zend\Session\SessionManager',
'VuFind\WorldCatUtils' => 'VuFind\Connection\WorldCatUtils', 'VuFind\WorldCatUtils' => 'VuFind\Connection\WorldCatUtils',
'VuFindTheme\ResourceContainer' => 'VuFind\Theme\ResourceContainer',
), ),
'initializers' => array( 'initializers' => array(
array('VuFind\ServiceManager\Initializer', 'initInstance'), array('VuFind\ServiceManager\Initializer', 'initInstance'),
......
...@@ -57,13 +57,6 @@ class Initializer ...@@ -57,13 +57,6 @@ class Initializer
*/ */
protected $event; protected $event;
/**
* Theme resource container
*
* @var ResourceContainer
*/
protected $resourceContainer;
/** /**
* Top-level service manager * Top-level service manager
* *
...@@ -96,9 +89,6 @@ class Initializer ...@@ -96,9 +89,6 @@ class Initializer
// Get base directory from tools object: // Get base directory from tools object:
$this->tools = $this->serviceManager->get('VuFindTheme\Tools'); $this->tools = $this->serviceManager->get('VuFindTheme\Tools');
$this->baseDir = $this->tools->getBaseDir(); $this->baseDir = $this->tools->getBaseDir();
// Grab the resource manager for tracking CSS, JS, etc.:
$this->resourceContainer = $this->tools->getResourceContainer();
} }
/** /**
...@@ -315,6 +305,9 @@ class Initializer ...@@ -315,6 +305,9 @@ class Initializer
{ {
$templatePathStack = array(); $templatePathStack = array();
// Grab the resource manager for tracking CSS, JS, etc.:
$resources = $this->serviceManager->get('VuFindTheme\ResourceContainer');
// Apply the loaded theme settings in reverse for proper inheritance: // Apply the loaded theme settings in reverse for proper inheritance:
foreach ($themes as $key=>$currentThemeInfo) { foreach ($themes as $key=>$currentThemeInfo) {
if ($helperNS = $currentThemeInfo->get('helper_namespace')) { if ($helperNS = $currentThemeInfo->get('helper_namespace')) {
...@@ -328,20 +321,20 @@ class Initializer ...@@ -328,20 +321,20 @@ class Initializer
// Add CSS and JS dependencies: // Add CSS and JS dependencies:
if ($css = $currentThemeInfo->get('css')) { if ($css = $currentThemeInfo->get('css')) {
$this->resourceContainer->addCss($css); $resources->addCss($css);
} }
if ($js = $currentThemeInfo->get('js')) { if ($js = $currentThemeInfo->get('js')) {
$this->resourceContainer->addJs($js); $resources->addJs($js);
} }
// Select encoding: // Select encoding:
if ($encoding = $currentThemeInfo->get('encoding')) { if ($encoding = $currentThemeInfo->get('encoding')) {
$this->resourceContainer->setEncoding($encoding); $resources->setEncoding($encoding);
} }
// Select favicon: // Select favicon:
if ($favicon = $currentThemeInfo->get('favicon')) { if ($favicon = $currentThemeInfo->get('favicon')) {
$this->resourceContainer->setFavicon($favicon); $resources->setFavicon($favicon);
} }
} }
......
...@@ -40,13 +40,13 @@ use Zend\View\Helper\AbstractHelper; ...@@ -40,13 +40,13 @@ use Zend\View\Helper\AbstractHelper;
class HeadThemeResources extends AbstractServiceLocator class HeadThemeResources extends AbstractServiceLocator
{ {
/** /**
* Get the theme tools. * Get the theme resource container.
* *
* @return \VuFind\Theme\Tools * @return \VuFind\Theme\ResourceContainer
*/ */
public function getThemeTools() public function getThemeResourceContainer()
{ {
return $this->getServiceLocator()->get('VuFindTheme\Tools'); return $this->getServiceLocator()->get('VuFindTheme\ResourceContainer');
} }
/** /**
...@@ -56,7 +56,7 @@ class HeadThemeResources extends AbstractServiceLocator ...@@ -56,7 +56,7 @@ class HeadThemeResources extends AbstractServiceLocator
*/ */
public function __invoke() public function __invoke()
{ {
$resourceContainer = $this->getThemeTools()->getResourceContainer(); $resourceContainer = $this->getThemeResourceContainer();
// Set up encoding: // Set up encoding:
$headMeta = $this->getView()->plugin('headmeta'); $headMeta = $this->getView()->plugin('headmeta');
......
...@@ -60,13 +60,6 @@ class Tools ...@@ -60,13 +60,6 @@ class Tools
*/ */
protected $safeTheme; protected $safeTheme;
/**
* Resource container
*
* @var ResourceContainer
*/
protected $resourceContainer;
/** /**
* Theme configuration * Theme configuration
* *
...@@ -83,7 +76,6 @@ class Tools ...@@ -83,7 +76,6 @@ class Tools
{ {
$this->baseDir = $baseDir; $this->baseDir = $baseDir;
$this->currentTheme = $this->safeTheme = $safeTheme; $this->currentTheme = $this->safeTheme = $safeTheme;
$this->resourceContainer = new ResourceContainer();
} }
/** /**
...@@ -96,17 +88,6 @@ class Tools ...@@ -96,17 +88,6 @@ class Tools
return $this->baseDir; return $this->baseDir;
} }
/**
* Get the container used for handling public resources for themes
* (CSS, JS, etc.)
*
* @return ResourceContainer
*/
public function getResourceContainer()
{
return $this->resourceContainer;
}
/** /**
* Get the configuration file for the specified theme. * Get the configuration file for the specified theme.
* *
......
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