ILIAS  trunk Revision v11.0_alpha-1713-gd8962da2f67
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
LinkProvider.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
25 use ILIAS\Data\URI;
30 
32 {
35 
36  public function __construct(
37  LinkFactory $link_factory,
38  PathFactory $path_factory
39  ) {
40  $this->link_factory = $link_factory;
41  $this->path_factory = $path_factory;
42  }
43 
44  public function create(
45  PathInterface $base_path,
46  ElementInterface $to_be_created
47  ): URI {
48  return $this->getLink(
49  $base_path,
50  $this->path_factory->toElement($to_be_created, true),
51  Command::CREATE_FULL
52  );
53  }
54 
55  public function update(
56  PathInterface $base_path,
57  ElementInterface $to_be_updated
58  ): URI {
59  return $this->getLink(
60  $base_path,
61  $this->path_factory->toElement($to_be_updated, true),
62  Command::UPDATE_FULL
63  );
64  }
65 
66  public function delete(
67  PathInterface $base_path,
68  ElementInterface $to_be_deleted
69  ): URI {
70  return $this->getLink(
71  $base_path,
72  $this->path_factory->toElement($to_be_deleted, true),
73  Command::DELETE_FULL
74  );
75  }
76 
77  protected function getLink(
78  PathInterface $base_path,
79  PathInterface $action_path,
80  Command $action_cmd
81  ): URI {
82  return $this->link_factory
83  ->custom($action_cmd)
84  ->withParameter(Parameter::BASE_PATH, $base_path->toString())
85  ->withParameter(Parameter::ACTION_PATH, $action_path->toString())
86  ->get();
87  }
88 }
getLink(PathInterface $base_path, PathInterface $action_path, Command $action_cmd)
create(PathInterface $base_path, ElementInterface $to_be_created)
__construct(LinkFactory $link_factory, PathFactory $path_factory)
update(PathInterface $base_path, ElementInterface $to_be_updated)