Neos\FluidAdaptor\ViewHelpers\Link\EmailViewHelper::render PHP Méthode

render() public méthode

public render ( string $email ) : string
$email string The email address to be turned into a link.
Résultat string Rendered email link
    public function render($email)
    {
        $linkHref = 'mailto:' . $email;
        $linkText = $email;
        $tagContent = $this->renderChildren();
        if ($tagContent !== null) {
            $linkText = $tagContent;
        }
        $this->tag->setContent($linkText);
        $this->tag->addAttribute('href', $linkHref);
        $this->tag->forceClosingTag(true);
        return $this->tag->render();
    }

Usage Example

 /**
  * @test
  */
 public function renderDoesNotAddEmptyScheme()
 {
     $mockTagBuilder = $this->createMock(TagBuilder::class, array('setTagName', 'addAttribute', 'setContent'));
     $mockTagBuilder->expects($this->any())->method('setTagName')->with('a');
     $mockTagBuilder->expects($this->once())->method('addAttribute')->with('href', 'some-domain.tld');
     $mockTagBuilder->expects($this->once())->method('setContent')->with('some content');
     $this->viewHelper->_set('tag', $mockTagBuilder);
     $this->viewHelper->expects($this->any())->method('renderChildren')->will($this->returnValue('some content'));
     $this->viewHelper->initialize();
     $this->viewHelper->render('some-domain.tld', '');
 }