ApiGen\Generator\Resolvers\RelativePathResolver::getRelativePath PHP Method

getRelativePath() public method

public getRelativePath ( string $fileName ) : string
$fileName string
return string
    public function getRelativePath($fileName)
    {
        foreach ($this->configuration->getOption(CO::SOURCE) as $directory) {
            if (strpos($fileName, $directory) === 0) {
                return $this->getFileNameWithoutSourcePath($fileName, $directory);
            }
        }
        throw new InvalidArgumentException(sprintf('Could not determine "%s" relative path', $fileName));
    }

Usage Example

Ejemplo n.º 1
0
 private function generateForElement(ElementReflectionInterface $element)
 {
     $template = $this->templateFactory->createNamedForElement('source', $element);
     $template = $this->namespaceAndPackageLoader->loadTemplateWithElementNamespaceOrPackage($template, $element);
     $template->setParameters(['fileName' => $this->relativePathResolver->getRelativePath($element->getFileName()), 'source' => $this->getHighlightedCodeFromElement($element)]);
     $template->save();
 }
All Usage Examples Of ApiGen\Generator\Resolvers\RelativePathResolver::getRelativePath