Commit | Line | Data |
---|---|---|
19b53e5b C |
1 | <?php |
2 | ||
380f3545 TO |
3 | /* |
4 | +--------------------------------------------------------------------+ | |
41498ac5 | 5 | | Copyright CiviCRM LLC. All rights reserved. | |
380f3545 | 6 | | | |
41498ac5 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 | ||
19b53e5b C |
13 | namespace Civi\Api4\Service\Spec\Provider; |
14 | ||
15 | use Civi\Api4\Service\Spec\RequestSpec; | |
16 | ||
016d95d3 | 17 | /** |
18 | * Class ContactTypeCreationSpecProvider | |
19 | * | |
20 | * @package Civi\Api4\Service\Spec\Provider | |
21 | */ | |
19b53e5b C |
22 | class ContactTypeCreationSpecProvider implements Generic\SpecProviderInterface { |
23 | ||
24 | /** | |
25 | * @param \Civi\Api4\Service\Spec\RequestSpec $spec | |
26 | */ | |
27 | public function modifySpec(RequestSpec $spec) { | |
28 | $spec->getFieldByName('label')->setRequired(TRUE); | |
29 | $spec->getFieldByName('name')->setRequired(TRUE); | |
30 | $spec->getFieldByName('parent_id')->setRequired(TRUE); | |
31 | ||
32 | } | |
33 | ||
34 | /** | |
35 | * @param string $entity | |
36 | * @param string $action | |
37 | * | |
38 | * @return bool | |
39 | */ | |
40 | public function applies($entity, $action) { | |
41 | return $entity === 'ContactType' && $action === 'create'; | |
42 | } | |
43 | ||
44 | } |