api4 - Import CRM/, Civi/, templates/, ang/, css/, js/, xml/menu
[civicrm-core.git] / Civi / Api4 / Route.php
1 <?php
2 namespace Civi\Api4;
3
4 use Civi\Api4\Generic\BasicGetFieldsAction;
5
6 class Route extends \Civi\Api4\Generic\AbstractEntity {
7
8 /**
9 * @return \Civi\Api4\Generic\BasicGetAction
10 */
11 public static function get() {
12 return new \Civi\Api4\Generic\BasicGetAction(__CLASS__, __FUNCTION__, function ($get) {
13 // Pulling from ::items() rather than DB -- because it provides the final/live/altered data.
14 $items = \CRM_Core_Menu::items();
15 $result = [];
16 foreach ($items as $path => $item) {
17 $result[] = ['path' => $path] + $item;
18 }
19 return $result;
20 });
21 }
22
23 public static function getFields() {
24 return new BasicGetFieldsAction(__CLASS__, __FUNCTION__, function() {
25 return [
26 [
27 'name' => 'path',
28 'title' => 'Relative Path',
29 'required' => TRUE,
30 'data_type' => 'String',
31 ],
32 [
33 'name' => 'title',
34 'title' => 'Page Title',
35 'required' => TRUE,
36 'data_type' => 'String',
37 ],
38 [
39 'name' => 'page_callback',
40 'title' => 'Page Callback',
41 'required' => TRUE,
42 'data_type' => 'String',
43 ],
44 [
45 'name' => 'page_arguments',
46 'title' => 'Page Arguments',
47 'required' => FALSE,
48 'data_type' => 'String',
49 ],
50 [
51 'name' => 'path_arguments',
52 'title' => 'Path Arguments',
53 'required' => FALSE,
54 'data_type' => 'String',
55 ],
56 [
57 'name' => 'access_arguments',
58 'title' => 'Access Arguments',
59 'required' => FALSE,
60 'data_type' => 'Array',
61 ],
62 ];
63 });
64 }
65
66 /**
67 * @return array
68 */
69 public static function permissions() {
70 return [
71 "meta" => ["access CiviCRM"],
72 "default" => ["administer CiviCRM"],
73 ];
74 }
75
76 }