ILIAS  trunk Revision v11.0_alpha-1731-gff9cd7e2bd3
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
PermanentLinkManager.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
28 
39 {
42 
43  public function __construct(
44  protected StaticUrl $static_url,
45  InternalGUIService $gui,
46  protected $ref_id = 0,
47  protected $wsp_id = 0
48  ) {
49  $this->gui = $gui;
50  if ($ref_id === 0 && !$wsp_id) {
51  $this->ref_id = $this->gui->standardRequest()->getRefId();
52  }
53  if ($wsp_id === 0 && !$ref_id) {
54  $this->wsp_id = $this->gui->standardRequest()->getWspId();
55  }
56  }
57 
58  public function getAppend(
59  int $posting = 0,
60  bool $edit = false
61  ): array {
62  $append = [];
63  if ($posting > 0) {
64  $append[] = $posting;
65  }
66  if ($edit) {
67  $append[] = "edit";
68  }
69  if ($this->ref_id === 0 && $this->wsp_id > 0) {
70  $append[] = "wsp";
71  }
72  return $append;
73  }
74 
75  public function getPermanentLink(
76  int $posting = 0,
77  bool $edit = false
78  ): string {
79  $id = $this->ref_id > 0
80  ? $this->ref_id
81  : $this->wsp_id;
82  $uri = $this->static_url->builder()->build(
83  'blog', // namespace
84  $id > 0 ? new ReferenceId($id) : null,
85  $this->getAppend($posting, $edit)
86  );
87  return (string) $uri;
88  }
89 
90  public function setPermanentLink(
91  int $posting = 0,
92  bool $edit = false
93  ): void {
94  $uri = $this->getPermanentLink($posting, $edit);
95  PageContentProvider::setPermaLink($uri);
96  }
97 }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
$static_url
Definition: goto.php:29
$ref_id
Definition: ltiauth.php:65
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23