avoid crash with one column and blank lines
[civicrm-core.git] / Civi / Api4 / Route.php
index 6681b645ecfb6294485ddfc40fb948f20a71cb2c..ec735eb8473703ae8b2ab7b480856381d269d976 100644 (file)
@@ -1,5 +1,4 @@
 <?php
-
 /*
  +--------------------------------------------------------------------+
  | Copyright CiviCRM LLC. All rights reserved.                        |
@@ -9,13 +8,6 @@
  | and copyright information, see https://civicrm.org/licensing       |
  +--------------------------------------------------------------------+
  */
-
-/**
- *
- * @package CRM
- * @copyright CiviCRM LLC https://civicrm.org/licensing
- */
-
 namespace Civi\Api4;
 
 /**
@@ -26,21 +18,21 @@ namespace Civi\Api4;
  * 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
+ * @searchable none
+ * @since 5.19
  * @package Civi\Api4
  */
 class Route extends \Civi\Api4\Generic\AbstractEntity {
 
   /**
    * @param bool $checkPermissions
-   * @return \Civi\Api4\Generic\BasicGetAction
+   * @return Generic\BasicGetAction
    */
   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();
+    return (new Generic\BasicGetAction(__CLASS__, __FUNCTION__, function ($get) {
       $result = [];
-      foreach ($items as $path => $item) {
+      // Pulling from ::items() rather than DB -- because it provides the final/live/altered data.
+      foreach (\CRM_Core_Menu::items() as $path => $item) {
         $result[] = ['path' => $path] + $item;
       }
       return $result;
@@ -57,37 +49,31 @@ class Route extends \Civi\Api4\Generic\AbstractEntity {
         [
           'name' => 'path',
           'title' => 'Relative Path',
-          'required' => TRUE,
           'data_type' => 'String',
         ],
         [
           'name' => 'title',
           'title' => 'Page Title',
-          'required' => TRUE,
           'data_type' => 'String',
         ],
         [
           'name' => 'page_callback',
           'title' => 'Page Callback',
-          'required' => TRUE,
           'data_type' => 'String',
         ],
         [
           'name' => 'page_arguments',
           'title' => 'Page Arguments',
-          'required' => FALSE,
           'data_type' => 'String',
         ],
         [
           'name' => 'path_arguments',
           'title' => 'Path Arguments',
-          'required' => FALSE,
           'data_type' => 'String',
         ],
         [
           'name' => 'access_arguments',
           'title' => 'Access Arguments',
-          'required' => FALSE,
           'data_type' => 'Array',
         ],
       ];