ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
PermanentLinkManager.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
26use ILIAS\StaticURL\Services as StaticUrl;
28
39{
42
43 public function __construct(
44 protected StaticUrl $static_url,
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}
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
Class Services.
Definition: Services.php:38
$static_url
Definition: goto.php:29
$ref_id
Definition: ltiauth.php:66