/**
  * {@inheritdoc}
  */
 public function onRouterBuilt(RouterBuiltEvent $event)
 {
     $this->router = $event->getRouter();
     $my_path = $this->getPath();
     $my_length = sizeof($my_path);
     $my_path = (string) $my_path;
     // If trying to get the parent raises an exception, we're going to
     // bail out. But we don't need the parent in order to find our own
     // children, so search for them before searching for the parent.
     $this->children = $this->router->filter(function (RouteWrapper $route) use($my_path, $my_length) {
         $path = $route->getPath();
         // <WTF>$path needs to be explicitly cast to a string, 'cause strPos() won't do
         // it, even though trim() and similar functions will.</WTF>
         return sizeof($path) == $my_length + 1 && strPos((string) $path, $my_path) === 0;
     })->ofType('MENU_LOCAL_TASK, MENU_DEFAULT_LOCAL_TASK, MENU_LOCAL_ACTION');
     try {
         $parent = $this->getPath()->getParent();
         $this->parent = $this->router->get($parent->__toString());
     } catch (\LengthException $e) {
         // Because there's no parent path, we can't effectively search for siblings.
         // Time to die.
         return;
     }
     $this->siblings = $this->router->filter(function (RouteWrapper $route) use($parent, $my_path, $my_length) {
         $path = $route->getPath();
         // <WTF>strPos(), <sarcasm>in its wisdom</sarcasm>, won't cast to string.</WTF>
         return $path !== $my_path && sizeof($path) == $my_length && strPos((string) $path, (string) $parent) === 0;
     });
 }
 /**
  * {@inheritdoc}
  */
 public function onRouterBuilt(RouterBuiltEvent $event)
 {
     $this->router = $event->getRouter();
     try {
         $parent = $this->getPath()->getParent()->__toString();
     } catch (\LengthException $e) {
         return;
     }
     // First, search the injected router for the parent route.
     foreach ($this->router as $route) {
         if ($route->getPath() == $parent) {
             $this->parent = $route;
         }
     }
     // Next, search the core route provider if no parent was found.
     if (empty($this->parent)) {
         $parents = $this->routeProvider->getRoutesByPattern($parent)->getIterator();
         if (sizeof($parents) > 0) {
             $this->parent = new static($parents->key(), $parents->current(), $this->routeProvider);
         }
     }
 }