Skip to content

Commit

Permalink
Civi ports
Browse files Browse the repository at this point in the history
https: //github.com/civicrm/civicrm-core/pull/25433
civicrm/civicrm-core#25482

Bug: T303986
Change-Id: Iafbe043e5103bf7582805e74e987bc550c56443b
  • Loading branch information
eileenmcnaughton authored and ejegg committed Jan 31, 2023
1 parent e328aee commit 64f6f92
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class GetSearchTasks extends \Civi\Api4\Generic\AbstractAction {

/**
* An array containing the searchDisplay definition
* @var array
* @var string|array
*/
protected $display;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
namespace Civi\Search;

use Civi\Api4\Action\SearchDisplay\AbstractRunAction;
use Civi\Api4\Entity;
use Civi\Api4\Extension;
use Civi\Api4\Query\SqlEquation;
use Civi\Api4\Query\SqlFunction;
Expand All @@ -30,6 +31,7 @@ class Admin {
* Returns clientside data needed for the `crmSearchAdmin` Angular module.
*
* @return array
* @throws \CRM_Core_Exception
*/
public static function getAdminSettings():array {
$schema = self::getSchema();
Expand Down Expand Up @@ -119,10 +121,11 @@ public static function getStyles():array {
* Fetch all entities the current user has permission to `get`.
*
* @return array[]
* @throws \CRM_Core_Exception
*/
public static function getSchema(): array {
$schema = [];
$entities = \Civi\Api4\Entity::get()
$entities = Entity::get()
->addSelect('name', 'title', 'title_plural', 'bridge_title', 'type', 'primary_key', 'description', 'label_field', 'icon', 'dao', 'bridge', 'ui_join_filters', 'searchable', 'order_by')
->addWhere('searchable', '!=', 'none')
->addOrderBy('title_plural')
Expand All @@ -141,11 +144,17 @@ public static function getSchema(): array {
if (!empty($paths['add'])) {
$entity['addPath'] = $paths['add'];
}
try {
$getFields = civicrm_api4($entity['name'], 'getFields', [
'select' => ['name', 'title', 'label', 'description', 'type', 'options', 'input_type', 'input_attrs', 'data_type', 'serialize', 'entity', 'fk_entity', 'readonly', 'operators', 'suffixes', 'nullable'],
'where' => [['deprecated', '=', FALSE], ['name', 'NOT IN', ['api_key', 'hash']]],
'orderBy' => ['label'],
]);
}
catch (\CRM_Core_Exception $e) {
\Civi::log()->warning('Entity could not be loaded', ['entity' => $entity['name']]);
continue;
}
foreach ($getFields as $field) {
$field['fieldName'] = $field['name'];
// Hack for RelationshipCache to make Relationship fields editable
Expand Down Expand Up @@ -408,7 +417,11 @@ private static function getJoinConditions(string $nearCol, string $farCol, strin
*
* @param string $alias
* @param array ...$entities
*
* @return array
*
* @throws \CRM_Core_Exception
* @throws \Civi\API\Exception\NotImplementedException
*/
private static function getJoinDefaults(string $alias, ...$entities):array {
$conditions = [];
Expand Down

0 comments on commit 64f6f92

Please sign in to comment.