public function getURL() { $routeName = null; $params = []; $metadata = null; /** @var ContextMetadataFactory $metadataFactory */ $metadataFactory = $this->pixie->container['vulnerability.context_metadata_factory']; if ($this->type == self::TYPE_CONTROLLER) { $metadata = $metadataFactory->getMetadata($this->getMappedTo(), null, $this->technology); $params = ['controller' => $this->getMappedTo()]; } else { if ($this->type == self::TYPE_ACTION && $this->getParent()) { $metadata = $metadataFactory->getMetadata($this->getParent()->getMappedTo(), $this->getMappedTo(), $this->technology); $params = ['controller' => $this->getParent() ? $this->getParent()->getMappedTo() : false, 'action' => $this->getMappedTo()]; } } if ($this->technology == self::TECH_REST) { if (!$metadata) { $metadata = new ContextMetadata(); } if (!$metadata->getRoute()) { $metadata->setRoute('rest'); } } /** @var Vuln\Route $annotation */ if ($metadata) { if ($metadata->getRoute()) { $routeName = $metadata->getRoute(); } else { $routeName = 'default'; } if (count($metadata->getRouteParams())) { $params = array_merge($params, $metadata->getRouteParams()); } if ($metadata->getDescription()) { $this->routeDescription = $metadata->getDescription(); } } if ($this->technology == self::TECH_REST) { if (!$params['controller']) { $params['controller'] = false; } } if ($routeName && in_array($this->technology, [self::TECH_GENERIC, self::TECH_WEB, self::TECH_REST])) { $url = $this->pixie->router->generateUrl($routeName, $params, false, 'http', false); if ($this->technology == self::TECH_REST && $params['action']) { $url .= ' [ ' . strtoupper($params['action']) . ' ]'; } return $url; } $url = $this->getParent() ? $this->getParent()->getURL() : new URL(); if (!is_object($url)) { $parentUrl = $url; $url = new URL(); $url->addSegment($parentUrl); } $url->setTechnology($this->getTechnology()); if ($this->getMappedTo() == 'default' && !$this->parent) { $url->addSegment('/'); } else { if ($this->type == self::TYPE_CONTROLLER) { $url->setService($this->getMappedTo()); } else { if ($this->type == self::TYPE_ACTION) { $url->setMethod($this->getMappedTo()); } else { $url->addSegment($this->getMappedTo()); } } } return $url; }