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 bool getIncludeCustom()
30 class DAOGetFieldsAction
extends BasicGetFieldsAction
{
33 * Include custom fields for this entity, or only core fields?
37 protected $includeCustom = TRUE;
40 * Get fields for a DAO-based entity.
44 protected function getRecords() {
45 $fields = $this->_itemsToGet('name');
46 /** @var \Civi\Api4\Service\Spec\SpecGatherer $gatherer */
47 $gatherer = \Civi
::container()->get('spec_gatherer');
48 // Any fields name with a dot in it is custom
50 $this->includeCustom
= strpos(implode('', $fields), '.') !== FALSE;
52 $spec = $gatherer->getSpec($this->getEntityName(), $this->getAction(), $this->includeCustom
, $this->values
);
53 return SpecFormatter
::specToArray($spec->getFields($fields), $this->loadOptions
, $this->values
);
56 public function fields() {
57 $fields = parent
::fields();
60 'data_type' => 'String',
63 'name' => 'help_post',
64 'data_type' => 'String',
67 'name' => 'column_name',
68 'data_type' => 'String',
71 'name' => 'custom_field_id',
72 'data_type' => 'Integer',
75 'name' => 'custom_group_id',
76 'data_type' => 'Integer',