4 +--------------------------------------------------------------------+
5 | Copyright CiviCRM LLC. All rights reserved. |
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 +--------------------------------------------------------------------+
16 * @copyright CiviCRM LLC https://civicrm.org/licensing
22 namespace Civi\Api4\Generic
;
24 use Civi\Api4\Service\Spec\SpecFormatter
;
28 * @method $this setIncludeCustom(bool $value)
29 * @method bool getIncludeCustom()
31 class DAOGetFieldsAction
extends BasicGetFieldsAction
{
34 * Include custom fields for this entity, or only core fields?
38 protected $includeCustom = TRUE;
41 * Get fields for a DAO-based entity.
45 protected function getRecords() {
46 $fields = $this->_itemsToGet('name');
47 /** @var \Civi\Api4\Service\Spec\SpecGatherer $gatherer */
48 $gatherer = \Civi
::container()->get('spec_gatherer');
49 // Any fields name with a dot in it is custom
51 $this->includeCustom
= strpos(implode('', $fields), '.') !== FALSE;
53 $spec = $gatherer->getSpec($this->getEntityName(), $this->getAction(), $this->includeCustom
, $this->values
);
54 return SpecFormatter
::specToArray($spec->getFields($fields), $this->loadOptions
, $this->values
);
57 public function fields() {
58 $fields = parent
::fields();
61 'data_type' => 'String',
64 'name' => 'help_post',
65 'data_type' => 'String',
68 'name' => 'custom_field_id',
69 'data_type' => 'Integer',
72 'name' => 'custom_group_id',
73 'data_type' => 'Integer',