ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
RepositoryLink.php
Go to the documentation of this file.
2 
6 use ilLink;
7 use ilObject2;
8 
18 {
19 
23  protected $ref_id = 0;
27  protected $alt_text;
31  protected $title = '';
32 
33 
39  public function withTitle(string $title) : hasTitle
40  {
41  $clone = clone($this);
42  $clone->title = $title;
43 
44  return $clone;
45  }
46 
47 
51  public function getTitle() : string
52  {
53  return $this->title !== null ? $this->title : ($this->getRefId() > 0 ? ilObject2::_lookupTitle(ilObject2::_lookupObjectId($this->getRefId())) : "");
54  }
55 
56 
62  public function withAltText(string $alt_text) : RepositoryLink
63  {
64  $clone = clone($this);
65  $clone->alt_text = $alt_text;
66 
67  return $clone;
68  }
69 
70 
74  public function getAltText() : string
75  {
76  return $this->alt_text;
77  }
78 
79 
83  final public function getAction() : string
84  {
85  return ilLink::_getLink($this->ref_id);
86  }
87 
88 
94  public function withAction(string $action) : hasAction
95  {
96  $clone = clone $this;
97  $clone->ref_id = (int) $action;
98 
99  return $clone;
100  }
101 
102 
108  public function withRefId(int $ref_id) : RepositoryLink
109  {
110  $clone = clone $this;
111  $clone->ref_id = $ref_id;
112 
113  return $clone;
114  }
115 
116 
120  public function getRefId() : int
121  {
122  return $this->ref_id;
123  }
124 
125 
129  public function withIsLinkToExternalAction(bool $is_external) : hasAction
130  {
131  throw new \LogicException("Repository-Links are always internal");
132  }
133 
134 
138  public function isLinkWithExternalAction() : bool
139  {
140  return false;
141  }
142 }
static _lookupTitle($a_id)
$action
static _lookupObjectId($a_ref_id)