blob: cd82d438f1aaac9c62ae5d689f3e4566faeb013c (
plain)
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
|
<?php
namespace Civi\Api4\Service\Spec\Provider;
use Civi\Api4\Service\Spec\FieldSpec;
use Civi\Api4\Service\Spec\RequestSpec;
class CustomValueSpecProvider implements SpecProviderInterface {
/**
* @inheritDoc
*/
public function modifySpec(RequestSpec $spec) {
$action = $spec->getAction();
if ($action !== 'create') {
$idField = new FieldSpec('id', $spec->getEntity(), 'Integer');
$idField->setTitle(ts('Custom Value ID'));
$spec->addFieldSpec($idField);
}
$entityField = new FieldSpec('entity_id', $spec->getEntity(), 'Integer');
$entityField->setTitle(ts('Entity ID'));
$entityField->setRequired($action === 'create');
$entityField->setFkEntity('Contact');
$spec->addFieldSpec($entityField);
}
/**
* @inheritDoc
*/
public function applies($entity, $action) {
return strstr($entity, 'Custom_');
}
}
|