ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
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 
47  protected array $relationships = [];
48 
49  public function __construct(string $action)
50  {
51  $this->action = $action;
52  }
53 
57  public function getAction(): string
58  {
59  return $this->action;
60  }
61 
65  public function withOpenInNewViewport(bool $open_in_new_viewport): C\Link\Link
66  {
67  $clone = clone $this;
68  $clone->open_in_new_viewport = $open_in_new_viewport;
69  return $clone;
70  }
71 
75  public function getOpenInNewViewport(): ?bool
76  {
78  }
79 
81  {
82  $clone = clone $this;
83  $clone->action_content_language = $language;
84  return $clone;
85  }
86 
88  {
90  }
91 
93  {
94  $clone = clone $this;
95  if (!in_array($type, $clone->relationships)) {
96  $clone->relationships[] = $type;
97  }
98  return $clone;
99  }
100 
104  public function getRelationshipsToReferencedResource(): array
105  {
106  $relationships = $this->relationships;
107  if (
108  $this->getOpenInNewViewport() &&
109  !in_array(C\Link\Relationship::NOOPENER, $relationships)
110  ) {
111  $relationships[] = C\Link\Relationship::NOOPENER;
112  }
113  return $relationships;
114  }
115 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
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