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
;
27 * Get fields for a DAO-based entity.
29 * @method $this setIncludeCustom(bool $value)
30 * @method bool getIncludeCustom()
32 class DAOGetFieldsAction
extends BasicGetFieldsAction
{
35 * Include custom fields for this entity, or only core fields?
39 protected $includeCustom = TRUE;
42 * Get fields for a DAO-based entity
46 protected function getRecords() {
47 $fields = $this->_itemsToGet('name');
48 /** @var \Civi\Api4\Service\Spec\SpecGatherer $gatherer */
49 $gatherer = \Civi
::container()->get('spec_gatherer');
50 // Any fields name with a dot in it is custom
52 $this->includeCustom
= strpos(implode('', $fields), '.') !== FALSE;
54 $spec = $gatherer->getSpec($this->getEntityName(), $this->getAction(), $this->includeCustom
);
55 return SpecFormatter
::specToArray($spec->getFields($fields), $this->loadOptions
);
58 public function fields() {
59 $fields = parent
::fields();
62 'data_type' => 'String',
65 'name' => 'help_post',
66 'data_type' => 'String',
69 'name' => 'custom_field_id',
70 'data_type' => 'Integer',
73 'name' => 'custom_group_id',
74 'data_type' => 'Integer',