Merge pull request #15338 from totten/master-poc-postcommit
[civicrm-core.git] / Civi / Api4 / Action / CustomValue / GetFields.php
1 <?php
2
3 /*
4 +--------------------------------------------------------------------+
5 | Copyright CiviCRM LLC. All rights reserved. |
6 | |
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 |
10 +--------------------------------------------------------------------+
11 */
12
13 /**
14 *
15 * @package CRM
16 * @copyright CiviCRM LLC https://civicrm.org/licensing
17 * $Id$
18 *
19 */
20
21 namespace Civi\Api4\Action\CustomValue;
22
23 use Civi\Api4\Service\Spec\SpecFormatter;
24
25 /**
26 * Get fields for a custom group.
27 */
28 class 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, $this->values);
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 }