Merge pull request #16424 from eileenmcnaughton/cont_setting_handling
[civicrm-core.git] / CRM / Api4 / Page / Api4Explorer.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 * $Id$
18 *
19 */
20 class CRM_Api4_Page_Api4Explorer extends CRM_Core_Page {
21
22 public function run() {
23 $apiDoc = new ReflectionFunction('civicrm_api4');
24 $vars = [
25 'operators' => \CRM_Core_DAO::acceptedSQLOperators(),
26 'basePath' => Civi::resources()->getUrl('civicrm'),
27 'schema' => (array) \Civi\Api4\Entity::get()->setChain(['fields' => ['$name', 'getFields']])->execute(),
28 'links' => (array) \Civi\Api4\Entity::getLinks()->execute(),
29 'docs' => \Civi\Api4\Utils\ReflectionUtils::parseDocBlock($apiDoc->getDocComment()),
30 ];
31 Civi::resources()
32 ->addVars('api4', $vars)
33 ->addPermissions(['access debug output'])
34 ->addScriptFile('civicrm', 'js/load-bootstrap.js')
35 ->addScriptFile('civicrm', 'bower_components/js-yaml/dist/js-yaml.min.js')
36 ->addScriptFile('civicrm', 'bower_components/google-code-prettify/bin/prettify.min.js')
37 ->addStyleFile('civicrm', 'bower_components/google-code-prettify/bin/prettify.min.css');
38
39 $loader = new Civi\Angular\AngularLoader();
40 $loader->setModules(['api4Explorer']);
41 $loader->setPageName('civicrm/api4');
42 $loader->useApp([
43 'defaultRoute' => '/explorer',
44 ]);
45 $loader->load();
46 parent::run();
47 }
48
49 }