ILIAS  trunk Revision v11.0_alpha-1749-g1a06bdef097
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
Link.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
23 use ILIAS\UI\Component as C;
29 
33 abstract class Link implements C\Link\Link
34 {
35  use ComponentHelper;
37  use HasHelpTopics;
39 
40  protected string $action;
41  protected ?bool $open_in_new_viewport = null;
43  protected bool $disabled = false;
44 
48  protected array $relationships = [];
49 
50  public function __construct(string $action)
51  {
52  $this->action = $action;
53  }
54 
58  public function getAction(): string
59  {
60  return $this->action;
61  }
62 
66  public function withOpenInNewViewport(bool $open_in_new_viewport): static
67  {
68  $clone = clone $this;
69  $clone->open_in_new_viewport = $open_in_new_viewport;
70  return $clone;
71  }
72 
76  public function getOpenInNewViewport(): ?bool
77  {
79  }
80 
81  public function withLanguageOfReferencedContent(LanguageTag $language): static
82  {
83  $clone = clone $this;
84  $clone->action_content_language = $language;
85  return $clone;
86  }
87 
89  {
91  }
92 
94  {
95  $clone = clone $this;
96  if (!in_array($type, $clone->relationships)) {
97  $clone->relationships[] = $type;
98  }
99  return $clone;
100  }
101 
105  public function getRelationshipsToReferencedResource(): array
106  {
107  $relationships = $this->relationships;
108  if (
109  $this->getOpenInNewViewport() &&
110  !in_array(C\Link\Relationship::NOOPENER, $relationships)
111  ) {
112  $relationships[] = C\Link\Relationship::NOOPENER;
113  }
114  return $relationships;
115  }
116 
117  public function withDisabled(bool $disabled = true): static
118  {
119  $clone = clone $this;
120  $clone->disabled = $disabled;
121  return $clone;
122  }
123 
124  public function isDisabled(): bool
125  {
126  return $this->disabled;
127  }
128 
129 }
trait JavaScriptBindable
Trait for components implementing JavaScriptBindable providing standard implementation.
This class represents a valid language tag that should be used instead of plain strings.
Definition: LanguageTag.php:39
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null