Merge pull request #24203 from colemanw/fixTagFilter553
[civicrm-core.git] / Civi / Api4 / ExampleData.php
CommitLineData
747156dd
TO
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
12namespace Civi\Api4;
13
14/**
15 * Search for example data.
16 *
17 * @searchable none
18 * @since 5.43
19 * @package Civi\Api4
20 */
bee4821d 21class ExampleData extends \Civi\Api4\Generic\AbstractEntity {
747156dd
TO
22
23 /**
24 * @param bool $checkPermissions
25 * @return Generic\AbstractGetAction
26 */
27 public static function get($checkPermissions = TRUE) {
bee4821d 28 return (new Action\ExampleData\Get(__CLASS__, __FILE__))
747156dd
TO
29 ->setCheckPermissions($checkPermissions);
30 }
31
32 /**
33 * @param bool $checkPermissions
34 * @return Generic\BasicGetFieldsAction
35 */
36 public static function getFields($checkPermissions = TRUE) {
37 return (new Generic\BasicGetFieldsAction(__CLASS__, __FUNCTION__, function () {
38 return [
39 [
40 'name' => 'name',
41 'title' => 'Example Name',
42 'data_type' => 'String',
43 ],
44 [
45 'name' => 'title',
46 'title' => 'Example Title',
47 'data_type' => 'String',
48 ],
49 [
50 'name' => 'workflow',
51 'title' => 'Workflow Name',
52 'data_type' => 'String',
53 ],
54 [
55 'name' => 'file',
56 'title' => 'File Path',
57 'data_type' => 'String',
58 'description' => 'If the example is loaded from a file, this is the location.',
59 ],
60 [
61 'name' => 'tags',
62 'title' => 'Tags',
ad6ea1b1
TO
63 'data_type' => 'Array',
64 'options' => [
65 'preview' => ts('Preview: Display as an example in the "Preview" dialog'),
66 'phpunit' => ts('PHPUnit: Run basic sniff tests in PHPUnit using this example'),
67 ],
747156dd
TO
68 ],
69 [
a37f134c 70 'type' => 'Extra',
747156dd
TO
71 'name' => 'data',
72 'title' => 'Example data',
73 'data_type' => 'String',
74 'serialize' => \CRM_Core_DAO::SERIALIZE_JSON,
75 ],
76 [
a37f134c 77 'type' => 'Extra',
747156dd
TO
78 'name' => 'asserts',
79 'title' => 'Test assertions',
80 'data_type' => 'String',
81 'serialize' => \CRM_Core_DAO::SERIALIZE_JSON,
82 ],
83 ];
84 }))->setCheckPermissions($checkPermissions);
85 }
86
87 /**
88 * @return array
89 */
90 public static function permissions() {
91 return [
92 // FIXME: Perhaps use 'edit message templates' or similar?
93 "meta" => ["access CiviCRM"],
94 "default" => ["administer CiviCRM"],
95 ];
96 }
97
a37f134c
TO
98 /**
99 * @inheritDoc
100 */
101 public static function getInfo() {
102 $info = parent::getInfo();
103 $info['primary_key'] = ['name'];
104 return $info;
105 }
106
747156dd 107}