APIv3 - Handle input errors
[civicrm-core.git] / CRM / Api4 / Page / Api4Explorer.php
CommitLineData
19b53e5b
C
1<?php
2
380f3545
TO
3/*
4 +--------------------------------------------------------------------+
bc77d7c0 5 | Copyright CiviCRM LLC. All rights reserved. |
380f3545 6 | |
bc77d7c0
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 */
19b53e5b
C
20class CRM_Api4_Page_Api4Explorer extends CRM_Core_Page {
21
22 public function run() {
9cea3619 23 $apiDoc = new ReflectionFunction('civicrm_api4');
19b53e5b
C
24 $vars = [
25 'operators' => \CRM_Core_DAO::acceptedSQLOperators(),
cdeee725 26 'basePath' => Civi::resources()->getUrl('civicrm'),
19b53e5b
C
27 'schema' => (array) \Civi\Api4\Entity::get()->setChain(['fields' => ['$name', 'getFields']])->execute(),
28 'links' => (array) \Civi\Api4\Entity::getLinks()->execute(),
9cea3619 29 'docs' => \Civi\Api4\Utils\ReflectionUtils::parseDocBlock($apiDoc->getDocComment()),
19b53e5b
C
30 ];
31 Civi::resources()
32 ->addVars('api4', $vars)
b65fa6dc 33 ->addPermissions(['access debug output'])
cdeee725 34 ->addScriptFile('civicrm', 'js/load-bootstrap.js')
0b873c9a 35 ->addScriptFile('civicrm', 'bower_components/js-yaml/dist/js-yaml.min.js')
136ca5bb 36 ->addScriptFile('civicrm', 'bower_components/marked/marked.min.js')
19b53e5b
C
37 ->addScriptFile('civicrm', 'bower_components/google-code-prettify/bin/prettify.min.js')
38 ->addStyleFile('civicrm', 'bower_components/google-code-prettify/bin/prettify.min.css');
39
40 $loader = new Civi\Angular\AngularLoader();
41 $loader->setModules(['api4Explorer']);
42 $loader->setPageName('civicrm/api4');
43 $loader->useApp([
44 'defaultRoute' => '/explorer',
45 ]);
46 $loader->load();
47 parent::run();
48 }
49
50}