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

Allow local override of xsl files (#1288)

- Also begin checking a root /xsl directory in preparation for possible future reorganization away from modules.
parent 015bc7a0
Branches
Tags
No related merge requests found
......@@ -41,6 +41,29 @@ use XSLTProcessor;
*/
class Processor
{
/**
* Locate an XSLT file and return its full path.
*
* @param string $xslt Filename
*
* @return string
* @throws \Exception
*/
protected static function findXslt($xslt)
{
$paths = [
LOCAL_OVERRIDE_DIR . '/xsl/',
APPLICATION_PATH . '/module/VuFind/xsl/',
APPLICATION_PATH . '/xsl/',
];
foreach ($paths as $path) {
if (file_exists($path . $xslt)) {
return $path . $xslt;
}
}
throw new \Exception('Cannot locate ' . $xslt);
}
/**
* Perform an XSLT transformation and return the results.
*
......@@ -53,8 +76,7 @@ class Processor
public static function process($xslt, $xml, $params = [])
{
$style = new DOMDocument();
// TODO: support local overrides
$style->load(APPLICATION_PATH . '/module/VuFind/xsl/' . $xslt);
$style->load(static::findXslt($xslt));
$xsl = new XSLTProcessor();
$xsl->importStyleSheet($style);
$doc = new DOMDocument();
......
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