ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
DIC.php
Go to the documentation of this file.
1 <?php
2 
21 
23 
28 trait DIC
29 {
33  public function dic()
34  {
35  global $DIC;
36  return $DIC;
37  }
38 
39  protected function ctrl(): \ilCtrl
40  {
41  return $this->dic()->ctrl();
42  }
43 
44  public function txt(string $variable): string
45  {
46  return $this->lng()->txt($variable);
47  }
48 
49 
50  protected function tpl(): \ilGlobalTemplateInterface
51  {
52  return $this->dic()->ui()->mainTemplate();
53  }
54 
55  protected function lng(): \ilLanguage
56  {
57  return $this->dic()->language();
58  }
59 
60  protected function tabs(): \ilTabsGUI
61  {
62  return $this->dic()->tabs();
63  }
64 
65  protected function ui(): \ILIAS\DI\UIServices
66  {
67  return $this->dic()->ui();
68  }
69 
70  protected function user(): \ilObjUser
71  {
72  return $this->dic()->user();
73  }
74 
75  protected function http(): \ILIAS\HTTP\Services
76  {
77  return $this->dic()->http();
78  }
79 
80  protected function access(): \ilAccessHandler
81  {
82  return $this->dic()->access();
83  }
84 
85  protected function toolbar(): \ilToolbarGUI
86  {
87  return $this->dic()->toolbar();
88  }
89 
90  protected function database(): \ilDBInterface
91  {
92  return $this->dic()->database();
93  }
94 
95  //
96  // Helper
97  //
98  public function checkPermissionAndFail($a_perm)
99  {
100  if (!$this->checkPermissionBoolAndReturn($a_perm)) {
101  throw new \ilObjectException($this->lng()->txt("permission_denied"));
102  }
103  }
104 
109  public function checkPermissionBoolAndReturn($a_perm)
110  {
111  return (bool) $this->access()->checkAccess($a_perm, '', $this->http()->request()->getQueryParams()['ref_id']);
112  }
113 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Interface Observer Contains several chained tasks and infos about them.
static http()
Fetches the global http state from ILIAS.
Class HTTPServicesTest.
global $DIC
Definition: shib_login.php:25
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...