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\Query\Api4SelectQuery
;
27 * Retrieve $ENTITIES based on criteria specified in the `where` parameter.
29 * Use the `select` param to determine which fields are returned, defaults to `[*]`.
31 * Perform joins on other related entities using a dot notation.
33 class DAOGetAction
extends AbstractGetAction
{
34 use Traits\DAOActionTrait
;
37 * Fields to return. Defaults to all non-custom fields `[*]`.
39 * Use the dot notation to perform joins in the select clause, e.g. selecting `['*', 'contact.*']` from `Email::get()`
40 * will select all fields for the email + all fields for the related contact.
45 protected $select = [];
48 * Field(s) by which to group the results.
52 protected $groupBy = [];
54 public function _run(Result
$result) {
55 $this->setDefaultWhereClause();
56 $this->expandSelectClauseWildcards();
57 $result->exchangeArray($this->getObjects());
63 protected function getObjects() {
64 $query = new Api4SelectQuery($this);
66 $result = $query->run();
67 if (is_array($result)) {
68 \CRM_Utils_API_HTMLInputCoder
::singleton()->decodeRows($result);
76 public function getGroupBy(): array {
77 return $this->groupBy
;
81 * @param array $groupBy
84 public function setGroupBy(array $groupBy) {
85 $this->groupBy
= $groupBy;
90 * @param string $field
93 public function addGroupBy(string $field) {
94 $this->groupBy
[] = $field;