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 | */ |
18 | ||
19b53e5b C |
19 | namespace Civi\Api4; |
20 | ||
0493ec47 CW |
21 | /** |
22 | * CiviCRM menu route. | |
23 | * | |
24 | * Provides page routes registered in the CiviCRM menu system. | |
25 | * | |
26 | * Note: this is a read-only api as routes are set via xml files and hooks. | |
27 | * | |
28 | * @see https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_alterMenu/ | |
09815e9c | 29 | * @searchable false |
0493ec47 CW |
30 | * @package Civi\Api4 |
31 | */ | |
19b53e5b C |
32 | class Route extends \Civi\Api4\Generic\AbstractEntity { |
33 | ||
34 | /** | |
6764a9d3 | 35 | * @param bool $checkPermissions |
f48d7e65 | 36 | * @return Generic\BasicGetAction |
19b53e5b | 37 | */ |
6764a9d3 | 38 | public static function get($checkPermissions = TRUE) { |
f48d7e65 | 39 | return (new Generic\BasicGetAction(__CLASS__, __FUNCTION__, function ($get) { |
19b53e5b | 40 | $result = []; |
f48d7e65 CW |
41 | // Pulling from ::items() rather than DB -- because it provides the final/live/altered data. |
42 | foreach (\CRM_Core_Menu::items() as $path => $item) { | |
19b53e5b C |
43 | $result[] = ['path' => $path] + $item; |
44 | } | |
45 | return $result; | |
6764a9d3 | 46 | }))->setCheckPermissions($checkPermissions); |
19b53e5b C |
47 | } |
48 | ||
6764a9d3 CW |
49 | /** |
50 | * @param bool $checkPermissions | |
51 | * @return Generic\BasicGetFieldsAction | |
52 | */ | |
53 | public static function getFields($checkPermissions = TRUE) { | |
54 | return (new Generic\BasicGetFieldsAction(__CLASS__, __FUNCTION__, function() { | |
19b53e5b C |
55 | return [ |
56 | [ | |
57 | 'name' => 'path', | |
58 | 'title' => 'Relative Path', | |
19b53e5b C |
59 | 'data_type' => 'String', |
60 | ], | |
61 | [ | |
62 | 'name' => 'title', | |
63 | 'title' => 'Page Title', | |
19b53e5b C |
64 | 'data_type' => 'String', |
65 | ], | |
66 | [ | |
67 | 'name' => 'page_callback', | |
68 | 'title' => 'Page Callback', | |
19b53e5b C |
69 | 'data_type' => 'String', |
70 | ], | |
71 | [ | |
72 | 'name' => 'page_arguments', | |
73 | 'title' => 'Page Arguments', | |
19b53e5b C |
74 | 'data_type' => 'String', |
75 | ], | |
76 | [ | |
77 | 'name' => 'path_arguments', | |
78 | 'title' => 'Path Arguments', | |
19b53e5b C |
79 | 'data_type' => 'String', |
80 | ], | |
81 | [ | |
82 | 'name' => 'access_arguments', | |
83 | 'title' => 'Access Arguments', | |
19b53e5b C |
84 | 'data_type' => 'Array', |
85 | ], | |
86 | ]; | |
6764a9d3 | 87 | }))->setCheckPermissions($checkPermissions); |
19b53e5b C |
88 | } |
89 | ||
90 | /** | |
91 | * @return array | |
92 | */ | |
93 | public static function permissions() { | |
94 | return [ | |
95 | "meta" => ["access CiviCRM"], | |
96 | "default" => ["administer CiviCRM"], | |
97 | ]; | |
98 | } | |
99 | ||
100 | } |