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 | ||
25 | class Route extends \Civi\Api4\Generic\AbstractEntity { | |
26 | ||
27 | /** | |
28 | * @return \Civi\Api4\Generic\BasicGetAction | |
29 | */ | |
30 | public static function get() { | |
31 | return new \Civi\Api4\Generic\BasicGetAction(__CLASS__, __FUNCTION__, function ($get) { | |
32 | // Pulling from ::items() rather than DB -- because it provides the final/live/altered data. | |
33 | $items = \CRM_Core_Menu::items(); | |
34 | $result = []; | |
35 | foreach ($items as $path => $item) { | |
36 | $result[] = ['path' => $path] + $item; | |
37 | } | |
38 | return $result; | |
39 | }); | |
40 | } | |
41 | ||
42 | public static function getFields() { | |
43 | return new BasicGetFieldsAction(__CLASS__, __FUNCTION__, function() { | |
44 | return [ | |
45 | [ | |
46 | 'name' => 'path', | |
47 | 'title' => 'Relative Path', | |
48 | 'required' => TRUE, | |
49 | 'data_type' => 'String', | |
50 | ], | |
51 | [ | |
52 | 'name' => 'title', | |
53 | 'title' => 'Page Title', | |
54 | 'required' => TRUE, | |
55 | 'data_type' => 'String', | |
56 | ], | |
57 | [ | |
58 | 'name' => 'page_callback', | |
59 | 'title' => 'Page Callback', | |
60 | 'required' => TRUE, | |
61 | 'data_type' => 'String', | |
62 | ], | |
63 | [ | |
64 | 'name' => 'page_arguments', | |
65 | 'title' => 'Page Arguments', | |
66 | 'required' => FALSE, | |
67 | 'data_type' => 'String', | |
68 | ], | |
69 | [ | |
70 | 'name' => 'path_arguments', | |
71 | 'title' => 'Path Arguments', | |
72 | 'required' => FALSE, | |
73 | 'data_type' => 'String', | |
74 | ], | |
75 | [ | |
76 | 'name' => 'access_arguments', | |
77 | 'title' => 'Access Arguments', | |
78 | 'required' => FALSE, | |
79 | 'data_type' => 'Array', | |
80 | ], | |
81 | ]; | |
82 | }); | |
83 | } | |
84 | ||
85 | /** | |
86 | * @return array | |
87 | */ | |
88 | public static function permissions() { | |
89 | return [ | |
90 | "meta" => ["access CiviCRM"], | |
91 | "default" => ["administer CiviCRM"], | |
92 | ]; | |
93 | } | |
94 | ||
95 | } |