comparison core/lib/Drupal/Core/GeneratedLink.php @ 0:4c8ae668cc8c

Initial import (non-working)
author Chris Cannam
date Wed, 29 Nov 2017 16:09:58 +0000
parents
children 7a779792577d
comparison
equal deleted inserted replaced
-1:000000000000 0:4c8ae668cc8c
1 <?php
2
3 namespace Drupal\Core;
4
5 use Drupal\Component\Render\MarkupInterface;
6 use Drupal\Component\Utility\Unicode;
7 use Drupal\Core\Render\BubbleableMetadata;
8
9 /**
10 * Used to return generated links, along with associated cacheability metadata.
11 *
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).
14 */
15 class GeneratedLink extends BubbleableMetadata implements MarkupInterface, \Countable {
16
17 /**
18 * HTML tag to use when building the link.
19 */
20 const TAG = 'a';
21
22 /**
23 * The HTML string value containing a link.
24 *
25 * @var string
26 */
27 protected $generatedLink = '';
28
29 /**
30 * Gets the generated link.
31 *
32 * @return string
33 */
34 public function getGeneratedLink() {
35 return $this->generatedLink ;
36 }
37
38 /**
39 * Sets the generated link.
40 *
41 * @param string $generated_link
42 * The generated link.
43 *
44 * @return $this
45 */
46 public function setGeneratedLink($generated_link) {
47 $this->generatedLink = $generated_link;
48 return $this;
49 }
50
51 /**
52 * {@inheritdoc}
53 */
54 public function __toString() {
55 return (string) $this->generatedLink;
56 }
57
58 /**
59 * {@inheritdoc}
60 */
61 public function jsonSerialize() {
62 return $this->__toString();
63 }
64
65 /**
66 * {@inheritdoc}
67 */
68 public function count() {
69 return Unicode::strlen($this->__toString());
70 }
71
72 }