0
@@ -343,8 +343,14 @@ class midcom_core_services_dispatcher_midgard implements midcom_core_services_di
0
* @param array $args associative arguments array
0
- public function generate_url($route_id, array $args
)
0
+ public function generate_url($route_id, array $args
, midgard_page $page = null)
0
+ $_MIDCOM->context->create();
0
+ $this->set_page($page);
0
+ $this->initialize($_MIDCOM->context->page->component);
0
$route_definitions = $this->get_routes();
0
if (!isset($route_definitions[$route_id]))
0
@@ -363,6 +369,14 @@ class midcom_core_services_dispatcher_midgard implements midcom_core_services_di
0
throw new UnexpectedValueException("Missing arguments matching route '{$route_id}' of {$this->component_name}: " . implode(', ', $link_remaining_args));
0
+ $url = preg_replace('%/{2,}%', '/', $this->get_page_prefix() . $link);
0
+ $_MIDCOM->context->delete();
0
return preg_replace('%/{2,}%', '/', $_MIDCOM->context->prefix . $link);
0
@@ -606,5 +620,60 @@ class midcom_core_services_dispatcher_midgard implements midcom_core_services_di
0
// Unlike in route_matches falling through means match
0
+ public function set_page(midgard_page $page)
0
+ $_MIDCOM->context->page = $page;
0
+ private function get_page_prefix()
0
+ if (!$_MIDCOM->context->page)
0
+ throw new Exception("No page set for the manual dispatcher");
0
+ $prefix = "{$_MIDGARD['prefix']}/";
0
+ $host_mc = midgard_host::new_collector('id', $_MIDGARD['host']);
0
+ $host_mc->set_key_property('root');
0
+ $roots = $host_mc->list_keys();
0
+ throw new Exception("Failed to load root page data for host {$_MIDGARD['host']}");
0
+ foreach ($roots as $root => $array)
0
+ if ($_MIDCOM->context->page->id == $root_id)
0
+ $page_id = $_MIDCOM->context->page->id;
0
+ && $page_id != $root_id)
0
+ $parent_mc = midgard_page::new_collector('id', $page_id);
0
+ $parent_mc->set_key_property('up');
0
+ $parent_mc->add_value_property('name');
0
+ $parent_mc->execute();
0
+ $parents = $parent_mc->list_keys();
0
+ foreach ($parents as $parent => $array)
0
+ $page_path = $parent_mc->get_subkey($parent, 'name') . "/{$page_path}";
0
+ return $prefix . $page_path;
Comments
No one has commented yet.