Merge pull request #15938 from civicrm/5.20
[civicrm-core.git] / Civi / Api4 / Action / CustomValue / GetFields.php
CommitLineData
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
13/**
14 *
15 * @package CRM
ca5cec67 16 * @copyright CiviCRM LLC https://civicrm.org/licensing
380f3545
TO
17 * $Id$
18 *
19 */
20
19b53e5b
C
21namespace Civi\Api4\Action\CustomValue;
22
23use Civi\Api4\Service\Spec\SpecFormatter;
24
25/**
26 * Get fields for a custom group.
27 */
28class GetFields extends \Civi\Api4\Generic\DAOGetFieldsAction {
29 use \Civi\Api4\Generic\Traits\CustomValueActionTrait;
30
31 protected function getRecords() {
32 $fields = $this->_itemsToGet('name');
33 /** @var \Civi\Api4\Service\Spec\SpecGatherer $gatherer */
34 $gatherer = \Civi::container()->get('spec_gatherer');
35 $spec = $gatherer->getSpec('Custom_' . $this->getCustomGroup(), $this->getAction(), $this->includeCustom);
36 return SpecFormatter::specToArray($spec->getFields($fields), $this->loadOptions);
37 }
38
39 /**
40 * @inheritDoc
41 */
42 public function getParamInfo($param = NULL) {
43 $info = parent::getParamInfo($param);
44 if (!$param) {
45 // This param is meaningless here.
46 unset($info['includeCustom']);
47 }
48 return $info;
49 }
50
51}