-
-
Notifications
You must be signed in to change notification settings - Fork 825
/
Copy pathEventCreationSpecProvider.php
68 lines (58 loc) · 2.68 KB
/
EventCreationSpecProvider.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<?php
/*
+--------------------------------------------------------------------+
| CiviCRM version 5 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2019 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
| CiviCRM is free software; you can copy, modify, and distribute it |
| under the terms of the GNU Affero General Public License |
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
| |
| CiviCRM is distributed in the hope that it will be useful, but |
| WITHOUT ANY WARRANTY; without even the implied warranty of |
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| See the GNU Affero General Public License for more details. |
| |
| You should have received a copy of the GNU Affero General Public |
| License and the CiviCRM Licensing Exception along |
| with this program; if not, contact CiviCRM LLC |
| at info[AT]civicrm[DOT]org. If you have questions about the |
| GNU Affero General Public License or the licensing of CiviCRM, |
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
+--------------------------------------------------------------------+
*/
/**
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2019
* $Id$
*
*/
namespace Civi\Api4\Service\Spec\Provider;
use Civi\Api4\Service\Spec\FieldSpec;
use Civi\Api4\Service\Spec\RequestSpec;
class EventCreationSpecProvider implements Generic\SpecProviderInterface {
/**
* @inheritDoc
*/
public function modifySpec(RequestSpec $spec) {
$spec->getFieldByName('event_type_id')->setRequiredIf('empty($values.template_id)');
$spec->getFieldByName('title')->setRequiredIf('empty($values.is_template)');
$spec->getFieldByName('start_date')->setRequiredIf('empty($values.is_template)');
$spec->getFieldByName('template_title')->setRequiredIf('!empty($values.is_template)');
$template_id = new FieldSpec('template_id', 'Event', 'Integer');
$template_id
->setTitle('Template Id')
->setDescription('Template on which to base this new event');
$spec->addFieldSpec($template_id);
}
/**
* @inheritDoc
*/
public function applies($entity, $action) {
return $entity === 'Event' && $action === 'create';
}
}