Skip to content
Browse files

Components loading uses drupal_static

  • Loading branch information...
1 parent ac4d45c commit 0bf9a0910d0f32645740efb3b507a14b91705e1f @shakty committed Apr 13, 2012
Showing with 34 additions and 8 deletions.
  1. +5 −0 CHANGELOG
  2. +12 −0 includes/components.inc
  3. +15 −6 includes/io.inc
  4. +1 −1 patterns.info
  5. +1 −1 patterns_components/patterns_components.module
View
5 CHANGELOG
@@ -1,3 +1,8 @@
+7053:
+
+ - patterns_io_load_components uses drupal_static now and returns an
+ array of paths to components
+
7052:
- SimpleTests re-enabled.
- General Test detached from patterns.test
View
12 includes/components.inc
@@ -0,0 +1,12 @@
+<?php
+/*
+ * @file
+ * Retrieves, sets information about Patterns components.
+ *
+ */
+
+function patterns_components_list($reset = FALSE) {
+ $components = patterns_io_load_components($reset);
+
+ return $components;
+}
View
21 includes/io.inc
@@ -34,24 +34,33 @@ function patterns_io_get_pattern_service($pattern) {
/**
* Loads the Patterns handlers (component) from the filesystem,
* if they are not already loaded.
+ *
+ * @param bool $reset (optional) If TRUE, always forces reloading
+ * the components from the file system. Defaults FALSE
+ *
+ * @return Array $components Array containing the paths of the
+ * components files.
*/
-function patterns_io_load_components() {
- static $loaded = FALSE;
-
- if ($loaded) {
- return;
+function patterns_io_load_components($reset = FALSE) {
+ $components = &drupal_static(__FUNCTION__);
+
+ if (isset($paths) && !$reset) {
+ return $components;
}
+ $components = array();
+
// Get list of directories to scan for components.
$paths = module_invoke_all('patterns_components');
foreach ($paths as $path) {
foreach (file_scan_directory($path, '/\.inc$/') as $file) {
require_once $file->uri;
+ $components[] = $file->uri;
}
}
- $loaded = TRUE;
+ return $components;
}
/**
View
2 patterns.info
@@ -5,7 +5,7 @@ dependencies[] = libraries
core = 7.x
version = 7.x-1.x-dev
-build = 7052
+build = 7053
package = Patterns
php = 5.2
View
2 patterns_components/patterns_components.module
@@ -3,7 +3,7 @@
/**
* Implements hook_patterns_components().
*
- * Tell the pattern engine where the components are.
+ * Tell the Patterns engine where the components are.
*/
function patterns_patterns_components() {
return drupal_get_path('module', 'patterns_components') . '/components/';

0 comments on commit 0bf9a09

Please sign in to comment.
Something went wrong with that request. Please try again.