public
Description: Midgard Components Framework 3rd generation
Homepage: http://www.midgard-project.org
Clone URL: git://github.com/bergie/midcom.git
Concept of "core routes" for running things like the admin UI
bergie (author)
Thu Feb 28 02:16:57 -0800 2008
commit  af00372bddd348bb957aadc8e7f59ae1bef98e47
tree    19e3790956688e59ef66753564d48d8af961b208
parent  256d6cb7d09d10376512d35826a17043da8531c1
...
62
63
64
65
 
66
67
68
...
62
63
64
 
65
66
67
68
0
@@ -62,7 +62,7 @@ class midcom_core_component_loader
0
         {
0
             // No component directory
0
             $this->tried_to_load[$component] = false;
0
-
0
+
0
             throw new OutOfRangeException("Component {$component} directory not found.");
0
         }
0
         
...
5
6
7
8
9
 
 
 
 
 
 
 
10
...
5
6
7
 
8
9
10
11
12
13
14
15
16
0
@@ -5,4 +5,10 @@ enable_included_list: false
0
 date_formats:
0
     short: '%d/%m/%Y'
0
     long: '%x %X'
0
-default_timezone: UTC
0
\ No newline at end of file
0
+default_timezone: UTC
0
+routes:
0
+ page_edit:
0
+ controller: midcom_core_controllers_page
0
+ action: edit
0
+ route: /__midcom/edit
0
+ content_entry_point: midcom-edit-page
0
\ No newline at end of file
...
20
21
22
 
 
23
24
25
...
20
21
22
23
24
25
26
27
0
@@ -20,6 +20,8 @@ interface midcom_core_services_dispatcher
0
     
0
     public function populate_environment_data();
0
     
0
+ public function get_routes();
0
+
0
     public function initialize($component);
0
     
0
     public function dispatch();
...
61
62
63
 
 
 
 
 
 
 
 
64
65
66
...
129
130
131
132
 
133
134
135
...
61
62
63
64
65
66
67
68
69
70
71
72
73
74
...
137
138
139
 
140
141
142
143
0
@@ -61,6 +61,14 @@ class midcom_core_services_dispatcher_manual implements midcom_core_services_dis
0
         }
0
     }
0
     
0
+ public function get_routes()
0
+ {
0
+ $core_routes = $_MIDCOM->configuration->get('routes');
0
+ $component_routes = $_MIDCOM->context->component_instance->configuration->get('routes');
0
+
0
+ return array_merge($core_routes, $component_routes);
0
+ }
0
+
0
     public function set_page(midgard_page $page)
0
     {
0
         $this->page = $page;
0
@@ -129,7 +137,7 @@ class midcom_core_services_dispatcher_manual implements midcom_core_services_dis
0
         {
0
             $_MIDCOM->timer->setMarker("MidCOM dispatcher::dispatch::{$this->component_name}");
0
         }
0
- $route_definitions = $_MIDCOM->context->component_instance->configuration->get('routes');
0
+ $route_definitions = $this->get_routes();
0
 
0
         $selected_route_configuration = $route_definitions[$this->route_id];
0
 
...
77
78
79
 
 
 
 
 
 
 
 
80
81
82
...
87
88
89
90
 
91
92
93
...
77
78
79
80
81
82
83
84
85
86
87
88
89
90
...
95
96
97
 
98
99
100
101
0
@@ -77,6 +77,14 @@ class midcom_core_services_dispatcher_midgard implements midcom_core_services_di
0
         $this->component_name = $component;
0
         $_MIDCOM->context->component_instance = $_MIDCOM->componentloader->load($this->component_name, $page);
0
     }
0
+
0
+ public function get_routes()
0
+ {
0
+ $core_routes = $_MIDCOM->configuration->get('routes');
0
+ $component_routes = $_MIDCOM->context->component_instance->configuration->get('routes');
0
+
0
+ return array_merge($core_routes, $component_routes);
0
+ }
0
 
0
     /**
0
      * Load a component and dispatch the request to it
0
@@ -87,7 +95,7 @@ class midcom_core_services_dispatcher_midgard implements midcom_core_services_di
0
         {
0
             $_MIDCOM->timer->setMarker('MidCOM dispatcher::dispatch');
0
         }
0
- $route_definitions = $_MIDCOM->context->component_instance->configuration->get('routes');
0
+ $route_definitions = $this->get_routes();
0
 
0
         $route_id_map = array();
0
         foreach ($route_definitions as $route_id => $route_configuration)
...
17
18
19
20
 
 
21
22
 
23
24
25
...
35
36
37
 
 
38
 
 
 
 
 
 
 
39
40
 
41
42
43
 
44
45
46
47
48
49
 
50
51
52
53
54
55
56
57
...
83
84
85
86
87
88
89
 
 
90
91
92
...
17
18
19
 
20
21
22
 
23
24
25
26
...
36
37
38
39
40
41
42
43
44
45
46
47
48
49
 
50
51
52
53
54
55
56
57
58
59
 
60
61
62
 
 
 
63
64
65
...
91
92
93
 
 
 
94
95
96
97
98
99
0
@@ -17,9 +17,10 @@ if (count($argv) != 2)
0
 }
0
 $conffile = $argv[1];
0
 
0
-if (!extension_loaded('midgard2'))
0
+if ( !extension_loaded('midgard')
0
+ && !extension_loaded('midgard2'))
0
 {
0
- die("Midgard 2 extension is not available\n");
0
+ die("Midgard extension is not available\n");
0
 }
0
 
0
 // Start up a Midgard connection
0
@@ -35,23 +36,30 @@ echo "Loading all components and their routes\n\n";
0
 // Go through the installed components
0
 foreach ($_MIDCOM->componentloader->manifests as $component_name => $manifest)
0
 {
0
+ // Enter new context
0
+ $_MIDCOM->context->create();
0
     $_MIDCOM->dispatcher->initialize($component_name);
0
+
0
+ if (!$_MIDCOM->context->component_instance)
0
+ {
0
+ echo "Skipping {$component_name}: component failed to load\n\n";
0
+ $_MIDCOM->context->delete();
0
+ continue;
0
+ }
0
 
0
- if (!$_MIDCOM->dispatcher->component_instance->configuration->exists('routes'))
0
+ if (!$_MIDCOM->context->component_instance->configuration->exists('routes'))
0
     {
0
         // No routes in this component, skip
0
         echo "Skipping {$component_name}: no routes\n\n";
0
+ $_MIDCOM->context->delete();
0
         continue;
0
     }
0
     
0
     echo "Running {$component_name}...\n";
0
     
0
- $routes = $_MIDCOM->dispatcher->component_instance->configuration->get('routes');
0
+ $routes = $_MIDCOM->dispatcher->get_routes();
0
     foreach ($routes as $route_id => $route_configuration)
0
     {
0
- // Enter new context
0
- $_MIDCOM->context->create();
0
-
0
         // Generate fake arguments
0
         preg_match_all('/\{\$(.+?)\}/', $route_configuration['route'], $route_path_matches);
0
         $route_string = $route_configuration['route'];
0
@@ -83,10 +91,9 @@ foreach ($_MIDCOM->componentloader->manifests as $component_name => $manifest)
0
         {
0
             echo " returned no data\n";
0
         }
0
-
0
- // Delete the context
0
- $_MIDCOM->context->delete();
0
     }
0
+ // Delete the context
0
+ $_MIDCOM->context->delete();
0
     echo "\n";
0
 }
0
 

Comments

    No one has commented yet.