Skip to content

Commit a6bfc9c

Browse files
author
Jason Smith
committed
Support the theme namespace discovery
1 parent 142879b commit a6bfc9c

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

patternkit.module

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,23 @@ function patternkit_pattern_libraries() {
9898
function patternkit_patternkit_library() {
9999
$libraries = array();
100100

101+
// Load patterns from this module for testing.
101102
$module_path = drupal_get_path('module', 'patternkit');
102103
$lib_path = $module_path . DIRECTORY_SEPARATOR . 'lib';
103104
$libraries[] = new PatternkitDrupalTwigLib('Example', $lib_path);
104105

106+
// Load patterns from themes exposing namespaces.
107+
foreach (list_themes() as $theme_name => $theme) {
108+
if ($theme->engine !== 'twig' || !isset($theme->info['namespaces'])) {
109+
continue;
110+
}
111+
foreach ($theme->info['namespaces'] as $namespace => $path) {
112+
$theme_path = dirname($theme->filename);
113+
$lib_path = $theme_path . DIRECTORY_SEPARATOR . $path;
114+
$libraries[] = new PatternkitDrupalTwigLib($namespace, $lib_path);
115+
}
116+
}
117+
105118
return $libraries;
106119
}
107120

src/PatternkitTwigWrapper.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
<?php
22
/**
33
* @file
4-
* customer-portal-kbase-copy
5-
*
6-
* - Created by jassmith on 2/2/18
4+
* Patternkit module - Twig wrapper.
75
*/
86

7+
/**
8+
* Class PatternkitTwigWrapper.
9+
*/
910
class PatternkitTwigWrapper {
1011

1112
protected $metadata;

0 commit comments

Comments
 (0)