Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[REF] Afform - Code cleanup in LoadAdminData API action #21089

Merged
merged 1 commit into from
Aug 11, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions ext/afform/admin/Civi/Api4/Action/Afform/LoadAdminData.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use Civi\AfformAdmin\AfformAdminMeta;
use Civi\Api4\Afform;
use Civi\Api4\Entity;
use Civi\Api4\Utils\CoreUtil;
use Civi\Api4\Query\SqlExpression;

/**
Expand Down Expand Up @@ -209,6 +209,10 @@ public function _run(\Civi\Api4\Generic\Result $result) {
$result[] = $info;
}

/**
* @param string $name
* @return array|null
*/
private function loadForm($name) {
return Afform::get($this->checkPermissions)
->setFormatWhitespace(TRUE)
Expand Down Expand Up @@ -262,10 +266,7 @@ private function getCalcFields($apiEntity, $apiParams) {
else {
$joinCount[$entityName] = 1;
}
$label = Entity::get(FALSE)
->addWhere('name', '=', $entityName)
->addSelect('title')
->execute()->first()['title'];
$label = CoreUtil::getInfoItem($entityName, 'title');
$joinMap[$alias] = $label . $num;
}

Expand All @@ -288,6 +289,9 @@ private function getCalcFields($apiEntity, $apiParams) {
return $calcFields;
}

/**
* @return array[]
*/
public function fields() {
return [
[
Expand Down