Commit | Line | Data |
---|---|---|
19b53e5b | 1 | <?php |
380f3545 TO |
2 | |
3 | /* | |
4 | +--------------------------------------------------------------------+ | |
41498ac5 | 5 | | Copyright CiviCRM LLC. All rights reserved. | |
380f3545 | 6 | | | |
41498ac5 TO |
7 | | This work is published under the GNU AGPLv3 license with some | |
8 | | permitted exceptions and without any warranty. For full license | | |
9 | | and copyright information, see https://civicrm.org/licensing | | |
380f3545 TO |
10 | +--------------------------------------------------------------------+ |
11 | */ | |
12 | ||
13 | /** | |
14 | * | |
15 | * @package CRM | |
ca5cec67 | 16 | * @copyright CiviCRM LLC https://civicrm.org/licensing |
380f3545 TO |
17 | * $Id$ |
18 | * | |
19 | */ | |
20 | ||
19b53e5b C |
21 | namespace Civi\Api4; |
22 | ||
23 | use Civi\Api4\Generic\BasicGetFieldsAction; | |
24 | ||
0493ec47 CW |
25 | /** |
26 | * CiviCRM menu route. | |
27 | * | |
28 | * Provides page routes registered in the CiviCRM menu system. | |
29 | * | |
30 | * Note: this is a read-only api as routes are set via xml files and hooks. | |
31 | * | |
32 | * @see https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_alterMenu/ | |
33 | * | |
34 | * @package Civi\Api4 | |
35 | */ | |
19b53e5b C |
36 | class Route extends \Civi\Api4\Generic\AbstractEntity { |
37 | ||
38 | /** | |
39 | * @return \Civi\Api4\Generic\BasicGetAction | |
40 | */ | |
41 | public static function get() { | |
42 | return new \Civi\Api4\Generic\BasicGetAction(__CLASS__, __FUNCTION__, function ($get) { | |
43 | // Pulling from ::items() rather than DB -- because it provides the final/live/altered data. | |
44 | $items = \CRM_Core_Menu::items(); | |
45 | $result = []; | |
46 | foreach ($items as $path => $item) { | |
47 | $result[] = ['path' => $path] + $item; | |
48 | } | |
49 | return $result; | |
50 | }); | |
51 | } | |
52 | ||
53 | public static function getFields() { | |
54 | return new BasicGetFieldsAction(__CLASS__, __FUNCTION__, function() { | |
55 | return [ | |
56 | [ | |
57 | 'name' => 'path', | |
58 | 'title' => 'Relative Path', | |
59 | 'required' => TRUE, | |
60 | 'data_type' => 'String', | |
61 | ], | |
62 | [ | |
63 | 'name' => 'title', | |
64 | 'title' => 'Page Title', | |
65 | 'required' => TRUE, | |
66 | 'data_type' => 'String', | |
67 | ], | |
68 | [ | |
69 | 'name' => 'page_callback', | |
70 | 'title' => 'Page Callback', | |
71 | 'required' => TRUE, | |
72 | 'data_type' => 'String', | |
73 | ], | |
74 | [ | |
75 | 'name' => 'page_arguments', | |
76 | 'title' => 'Page Arguments', | |
77 | 'required' => FALSE, | |
78 | 'data_type' => 'String', | |
79 | ], | |
80 | [ | |
81 | 'name' => 'path_arguments', | |
82 | 'title' => 'Path Arguments', | |
83 | 'required' => FALSE, | |
84 | 'data_type' => 'String', | |
85 | ], | |
86 | [ | |
87 | 'name' => 'access_arguments', | |
88 | 'title' => 'Access Arguments', | |
89 | 'required' => FALSE, | |
90 | 'data_type' => 'Array', | |
91 | ], | |
92 | ]; | |
93 | }); | |
94 | } | |
95 | ||
96 | /** | |
97 | * @return array | |
98 | */ | |
99 | public static function permissions() { | |
100 | return [ | |
101 | "meta" => ["access CiviCRM"], | |
102 | "default" => ["administer CiviCRM"], | |
103 | ]; | |
104 | } | |
105 | ||
106 | } |