APIv4 - Add "Permission.get" for browsing available permissions.
[civicrm-core.git] / Civi / Api4 / Route.php
index f3d36bc61cbce6315a0bd6ee53861a09a9f14538..6681b645ecfb6294485ddfc40fb948f20a71cb2c 100644 (file)
  *
  * @package CRM
  * @copyright CiviCRM LLC https://civicrm.org/licensing
- * $Id$
- *
  */
 
 namespace Civi\Api4;
 
-use Civi\Api4\Generic\BasicGetFieldsAction;
-
 /**
  * CiviCRM menu route.
  *
@@ -30,16 +26,17 @@ use Civi\Api4\Generic\BasicGetFieldsAction;
  * Note: this is a read-only api as routes are set via xml files and hooks.
  *
  * @see https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_alterMenu/
- *
+ * @searchable false
  * @package Civi\Api4
  */
 class Route extends \Civi\Api4\Generic\AbstractEntity {
 
   /**
+   * @param bool $checkPermissions
    * @return \Civi\Api4\Generic\BasicGetAction
    */
-  public static function get() {
-    return new \Civi\Api4\Generic\BasicGetAction(__CLASS__, __FUNCTION__, function ($get) {
+  public static function get($checkPermissions = TRUE) {
+    return (new \Civi\Api4\Generic\BasicGetAction(__CLASS__, __FUNCTION__, function ($get) {
       // Pulling from ::items() rather than DB -- because it provides the final/live/altered data.
       $items = \CRM_Core_Menu::items();
       $result = [];
@@ -47,11 +44,15 @@ class Route extends \Civi\Api4\Generic\AbstractEntity {
         $result[] = ['path' => $path] + $item;
       }
       return $result;
-    });
+    }))->setCheckPermissions($checkPermissions);
   }
 
-  public static function getFields() {
-    return new BasicGetFieldsAction(__CLASS__, __FUNCTION__, function() {
+  /**
+   * @param bool $checkPermissions
+   * @return Generic\BasicGetFieldsAction
+   */
+  public static function getFields($checkPermissions = TRUE) {
+    return (new Generic\BasicGetFieldsAction(__CLASS__, __FUNCTION__, function() {
       return [
         [
           'name' => 'path',
@@ -90,7 +91,7 @@ class Route extends \Civi\Api4\Generic\AbstractEntity {
           'data_type' => 'Array',
         ],
       ];
-    });
+    }))->setCheckPermissions($checkPermissions);
   }
 
   /**