- $next = array_shift($path);
- $alias = null;
- if ($next && $next{0} == '%') {
- $alias = $next;
- $next = $platal->hook_map(substr($next, 1));
- }
- if (!$next) {
- return;
- }
- @$child =& $this->children[$next];
- if (!$child) {
- $child = new PlHookTree();
- $this->children[$next] =& $child;
- $child->aliased = $alias;
- }
- if (empty($path)) {
- $child->hook = $hook;
- } else {
- $child->addChild($path, $hook);
- }
- }
-
- private function findChildAux(array $remain, array $matched, array $aliased)
- {
- $next = @$remain[0];
- if ($this->aliased) {
- $aliased = $matched;
- }
- if (!empty($next)) {
- $child = @$this->children[$next];
- if ($child) {
- array_shift($remain);
- $matched[] = $next;
- return $child->findChildAux($remain, $matched, $aliased);
+ foreach ($hooks as $path=>$hook) {
+ $path = explode('/', $path);
+ $element = $this;
+ foreach ($path as $next) {
+ $alias = null;
+ if ($next{0} == '%') {
+ $alias = $next;
+ $next = $platal->hook_map(substr($next, 1));
+ }
+ if (!isset($element->children[$next])) {
+ $child = new PlHookTree();
+ $child->aliased = $alias;
+ $element->children[$next] = $child;
+ } else {
+ $child = $element->children[$next];
+ }
+ $element = $child;