5 use Drupal\Component\Render\MarkupInterface;
6 use Drupal\Component\Utility\Unicode;
7 use Drupal\Core\Render\BubbleableMetadata;
10 * Used to return generated links, along with associated cacheability metadata.
12 * Note: not to be confused with \Drupal\Core\Link, which is for passing around
13 * ungenerated links (typically link text + route name + route parameters).
15 class GeneratedLink extends BubbleableMetadata implements MarkupInterface, \Countable {
18 * HTML tag to use when building the link.
23 * The HTML string value containing a link.
27 protected $generatedLink = '';
30 * Gets the generated link.
34 public function getGeneratedLink() {
35 return $this->generatedLink ;
39 * Sets the generated link.
41 * @param string $generated_link
46 public function setGeneratedLink($generated_link) {
47 $this->generatedLink = $generated_link;
54 public function __toString() {
55 return (string) $this->generatedLink;
61 public function jsonSerialize() {
62 return $this->__toString();
68 public function count() {
69 return Unicode::strlen($this->__toString());