/**
  * Generates a Markdown link to the given Descriptor or returns the link text if no route to the Descriptor could
  * be matched.
  *
  * @param DescriptorAbstract $element
  * @param string             $link
  * @param string             $description
  *
  * @return string
  */
 private function resolveElement(DescriptorAbstract $element, $link, $description)
 {
     $rule = $this->router->match($element);
     if ($rule) {
         $url = '..' . $rule->generate($element);
         $link = $this->generateMarkdownLink($url, $description ?: $link);
     }
     return $link;
 }
 /**
  * Adds the 'inherited_from' tag when a Descriptor inherits from another Descriptor.
  *
  * @param \DOMElement        $docBlock
  * @param DescriptorAbstract $descriptor
  *
  * @return void
  */
 protected function addInheritedFromTag(\DOMElement $docBlock, $descriptor)
 {
     $parentElement = $descriptor->getInheritedElement();
     if (!$parentElement instanceof $descriptor) {
         return;
     }
     $child = new \DOMElement('tag');
     $docBlock->appendChild($child);
     $rule = $this->router->match($parentElement);
     $child->setAttribute('name', 'inherited_from');
     $child->setAttribute('description', $parentElement->getFullyQualifiedStructuralElementName());
     $child->setAttribute('refers', $parentElement->getFullyQualifiedStructuralElementName());
     $child->setAttribute('link', $rule ? $rule->generate($parentElement) : '');
 }
 /**
  * @covers phpDocumentor\Plugin\Core\Transformer\Writer\Xml\DocBlockConverter::convert
  * @covers phpDocumentor\Plugin\Core\Transformer\Writer\Xml\DocBlockConverter::addInheritedFromTag
  */
 public function testAddInheritedFromTag()
 {
     // Arrange
     $fqcn = 'fqcn';
     $url = 'url';
     $parent = $this->prepareParentXMLElement();
     $parentDescriptor = $this->givenADescriptor()->shouldReceive('getFullyQualifiedStructuralElementName')->andReturn($fqcn)->getMock();
     $descriptor = $this->givenADescriptorWithSummaryDescriptionAndTags('summary', 'description', array())->shouldReceive('getInheritedElement')->andReturn($parentDescriptor)->getMock();
     $ruleMock = $this->givenARuleThatGeneratesTheGivenUrl($url);
     $this->routerMock->shouldReceive('match')->with($parentDescriptor)->andReturn($ruleMock);
     // Act
     $this->fixture->convert($parent, $descriptor);
     // Assert
     $this->assertSame('inherited_from', $parent->getElementsByTagName('tag')->item(0)->getAttribute('name'));
     $this->assertSame($fqcn, $parent->getElementsByTagName('tag')->item(0)->getAttribute('refers'));
     $this->assertSame($fqcn, $parent->getElementsByTagName('tag')->item(0)->getAttribute('description'));
     $this->assertSame($url, $parent->getElementsByTagName('tag')->item(0)->getAttribute('link'));
 }
 /**
  * Initializes this router with a list of all elements.
  *
  * @param ProjectDescriptorBuilder $projectDescriptorBuilder
  */
 public function __construct(ProjectDescriptorBuilder $projectDescriptorBuilder)
 {
     $this->projectDescriptorBuilder = $projectDescriptorBuilder;
     parent::__construct();
 }
 /**
  * Registers the application configuration with this router.
  *
  * The configuration is used to extract which external routes to add to the application.
  *
  * @param Configuration $configuration
  */
 public function __construct(Configuration $configuration)
 {
     $this->configuration = $configuration;
     parent::__construct();
 }