Search ext: Add searchDisplay and searchPage modules
[civicrm-core.git] / ext / search / CRM / Search / Page / Admin.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
5 | |
6 | This work is published under the GNU AGPLv3 license with some |
7 | permitted exceptions and without any warranty. For full license |
8 | and copyright information, see https://civicrm.org/licensing |
9 +--------------------------------------------------------------------+
10 */
11
12 /**
13 * Angular base page for search admin
14 */
15 class CRM_Search_Page_Admin extends CRM_Core_Page {
16
17 public function run() {
18 $breadCrumb = [
19 'title' => ts('Search Kit'),
20 'url' => CRM_Utils_System::url('civicrm/admin/search', NULL, FALSE, '/list'),
21 ];
22 CRM_Utils_System::appendBreadCrumb([$breadCrumb]);
23
24 $schema = \Civi\Search\Admin::getSchema();
25
26 // If user does not have permission to search any entity, bye bye.
27 if (!$schema) {
28 CRM_Utils_System::permissionDenied();
29 }
30
31 // Add client-side vars for the search UI
32 $vars = [
33 'schema' => $schema,
34 'links' => \Civi\Search\Admin::getLinks(array_column($schema, 'name')),
35 ];
36
37 Civi::resources()
38 ->addBundle('bootstrap3')
39 ->addVars('search', $vars);
40
41 // Load angular module
42 $loader = new Civi\Angular\AngularLoader();
43 $loader->setPageName('civicrm/admin/search');
44 $loader->useApp([
45 'defaultRoute' => '/list',
46 ]);
47 $loader->load();
48 parent::run();
49 }
50
51 }