0
@@ -17,6 +17,8 @@ class midcom_core_component_loader
0
public $authors = array();
0
private $tried_to_load = array();
0
private $interfaces = array();
0
+ private $process_injectors = array();
0
+ private $template_injectors = array();
0
public function __construct()
0
@@ -188,12 +190,44 @@ class midcom_core_component_loader
0
$this->manifests[$manifest['component']] = $manifest;
0
+ if (isset($manifest['process_injector']))
0
+ // This component has an injector for the process() phase
0
+ $this->process_injectors[$manifest['component']] = $manifest['process_injector'];
0
+ if (isset($manifest['template_injector']))
0
+ // This component has an injector for the template() phase
0
+ $this->template_injectors[$manifest['component']] = $manifest['template_injector'];
0
private function load_all_manifests()
0
- exec('find ' . escapeshellarg(MIDCOM_ROOT) . ' -follow -type f -name ' . escapeshellarg('manifest.yml'), $manifests);
0
+ if (!class_exists('Memcache'))
0
+ // Uncached manifest loading is very slow
0
+ exec('find ' . escapeshellarg(MIDCOM_ROOT) . ' -follow -type f -name ' . escapeshellarg('manifest.yml'), $manifests);
0
+ foreach ($manifests as $manifest)
0
+ if (strpos($manifest, 'scaffold') === false)
0
+ $this->load_manifest($manifest);
0
+ // TODO: Refactor to utilize cache service infrastructure
0
+ $memcache = new Memcache;
0
+ $memcache->connect('localhost');
0
+ if (!$manifests = $memcache->get('manifests'))
0
+ exec('find ' . escapeshellarg(MIDCOM_ROOT) . ' -follow -type f -name ' . escapeshellarg('manifest.yml'), $manifests);
0
+ $memcache->set('manifests', $manifests, false, 600);
0
foreach ($manifests as $manifest)
0
if (strpos($manifest, 'scaffold') === false)
0
@@ -201,6 +235,37 @@ class midcom_core_component_loader
0
$this->load_manifest($manifest);
0
+ * Injectors are component classes that manipulate the context
0
+ private function inject($injector_type)
0
+ $injector_array = "{$injector_type}_injectors";
0
+ $injector_method = "inject_{$injector_type}";
0
+ foreach ($this->$injector_array as $component => $injector_class)
0
+ // Ensure the component is loaded
0
+ $this->load($component);
0
+ // Instantiate the injector class
0
+ $injector = new $injector_class();
0
+ $injector->$injector_method();
0
+ public function inject_process()
0
+ $this->inject('process');
0
+ public function inject_template()
0
+ $this->inject('process');
0
\ No newline at end of file
Comments
No one has commented yet.