Pull merge.
[yaffs-website] / web / core / lib / Drupal / Core / GeneratedLink.php
1 <?php
2
3 namespace Drupal\Core;
4
5 use Drupal\Component\Render\MarkupInterface;
6 use Drupal\Core\Render\BubbleableMetadata;
7
8 /**
9  * Used to return generated links, along with associated cacheability metadata.
10  *
11  * Note: not to be confused with \Drupal\Core\Link, which is for passing around
12  *   ungenerated links (typically link text + route name + route parameters).
13  */
14 class GeneratedLink extends BubbleableMetadata implements MarkupInterface, \Countable {
15
16   /**
17    * HTML tag to use when building the link.
18    */
19   const TAG = 'a';
20
21   /**
22    * The HTML string value containing a link.
23    *
24    * @var string
25    */
26   protected $generatedLink = '';
27
28   /**
29    * Gets the generated link.
30    *
31    * @return string
32    */
33   public function getGeneratedLink() {
34     return $this->generatedLink;
35   }
36
37   /**
38    * Sets the generated link.
39    *
40    * @param string $generated_link
41    *   The generated link.
42    *
43    * @return $this
44    */
45   public function setGeneratedLink($generated_link) {
46     $this->generatedLink = $generated_link;
47     return $this;
48   }
49
50   /**
51    * {@inheritdoc}
52    */
53   public function __toString() {
54     return (string) $this->generatedLink;
55   }
56
57   /**
58    * {@inheritdoc}
59    */
60   public function jsonSerialize() {
61     return $this->__toString();
62   }
63
64   /**
65    * {@inheritdoc}
66    */
67   public function count() {
68     return mb_strlen($this->__toString());
69   }
70
71 }