Unverified Commit 27178a9c authored by RobLoach's avatar RobLoach

Issue #2852837 by RobLoach: Use addPath() rather than addPaths()

parent bc125626
......@@ -84,42 +84,13 @@ class ComponentLibraryLoader extends \Twig_Loader_Filesystem {
}
}
// Since the components module does not have any Twig templates, we can
// safely let a component library override its namespace.
$existing_namespaces = array_diff($existing_namespaces, array('components'));
$overridden_namespaces = array();
// Decide if we should register each component library found.
// Register the library paths.
foreach ($this->libraries as &$library) {
// The component library's paths must exist.
if (empty($library['paths'])) {
$library['error'] = 'Paths are not defined.';
}
else {
if (isset($library['paths'])) {
foreach ($library['paths'] as $path) {
if (!$library['error'] && !is_dir($path)) {
$library['error'] = 'Path does not exist: "' . $path . '"';
}
}
}
// Don't override an existing namespace.
if (!$library['error']) {
// Allow a theme or module to override its own namespace.
if ($library['namespace'] === $library['name'] && !in_array($library['name'], $overridden_namespaces)) {
$overridden_namespaces[] = $library['name'];
}
elseif (in_array($library['namespace'], $existing_namespaces)) {
$library['error'] = 'Namespace already exists.';
$this->addPath($path, $library['namespace']);
}
}
// Register the Twig namespace if no errors.
if (!$library['error']) {
$this->setPaths($library['paths'], $library['namespace']);
$existing_namespaces[] = $library['namespace'];
}
}
}
}
Markdown is supported
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