Merge pull request #19765 from colemanw/inPlaceEdit
[civicrm-core.git] / Civi / Api4 / Route.php
1 <?php
2
3 /*
4 +--------------------------------------------------------------------+
5 | Copyright CiviCRM LLC. All rights reserved. |
6 | |
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 |
10 +--------------------------------------------------------------------+
11 */
12
13 /**
14 *
15 * @package CRM
16 * @copyright CiviCRM LLC https://civicrm.org/licensing
17 */
18
19 namespace Civi\Api4;
20
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/
29 * @searchable false
30 * @package Civi\Api4
31 */
32 class Route extends \Civi\Api4\Generic\AbstractEntity {
33
34 /**
35 * @param bool $checkPermissions
36 * @return Generic\BasicGetAction
37 */
38 public static function get($checkPermissions = TRUE) {
39 return (new Generic\BasicGetAction(__CLASS__, __FUNCTION__, function ($get) {
40 $result = [];
41 // Pulling from ::items() rather than DB -- because it provides the final/live/altered data.
42 foreach (\CRM_Core_Menu::items() as $path => $item) {
43 $result[] = ['path' => $path] + $item;
44 }
45 return $result;
46 }))->setCheckPermissions($checkPermissions);
47 }
48
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() {
55 return [
56 [
57 'name' => 'path',
58 'title' => 'Relative Path',
59 'data_type' => 'String',
60 ],
61 [
62 'name' => 'title',
63 'title' => 'Page Title',
64 'data_type' => 'String',
65 ],
66 [
67 'name' => 'page_callback',
68 'title' => 'Page Callback',
69 'data_type' => 'String',
70 ],
71 [
72 'name' => 'page_arguments',
73 'title' => 'Page Arguments',
74 'data_type' => 'String',
75 ],
76 [
77 'name' => 'path_arguments',
78 'title' => 'Path Arguments',
79 'data_type' => 'String',
80 ],
81 [
82 'name' => 'access_arguments',
83 'title' => 'Access Arguments',
84 'data_type' => 'Array',
85 ],
86 ];
87 }))->setCheckPermissions($checkPermissions);
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 }