ApiGen\Templating\Filters\SourceFilters::sourceUrl PHP Method

sourceUrl() public method

public sourceUrl ( ApiGen\Contracts\Parser\Reflection\ElementReflectionInterface $element, boolean $withLine = true ) : string
$element ApiGen\Contracts\Parser\Reflection\ElementReflectionInterface
$withLine boolean Include file line number into the link
return string
    public function sourceUrl(ElementReflectionInterface $element, $withLine = true)
    {
        $file = '';
        if ($this->isDirectUrl($element)) {
            $elementName = $element->getName();
            if ($element instanceof ClassReflectionInterface) {
                $file = 'class-';
            } elseif ($element instanceof ConstantReflectionInterface) {
                $file = 'constant-';
            } elseif ($element instanceof FunctionReflectionInterface) {
                $file = 'function-';
            }
        } else {
            $elementName = $element->getDeclaringClassName();
            $file = 'class-';
        }
        $file .= $this->urlize($elementName);
        $url = sprintf($this->configuration->getOption('template')['templates']['source']['filename'], $file);
        if ($withLine) {
            $url .= $this->getElementLinesAnchor($element);
        }
        return $url;
    }

Usage Example

 /**
  * @return string
  */
 public function getTemplatePathForSourceElement(ElementReflectionInterface $element)
 {
     return $this->getDestination() . '/' . $this->sourceFilters->sourceUrl($element, FALSE);
 }