Skip to content

Commit

Permalink
Merge pull request #27182 from civicrm/5.65
Browse files Browse the repository at this point in the history
5.65
  • Loading branch information
seamuslee001 authored Aug 27, 2023
2 parents 6821fd8 + 6a23f6b commit 44fa0ef
Show file tree
Hide file tree
Showing 5 changed files with 542 additions and 3 deletions.
45 changes: 45 additions & 0 deletions Civi/Api4/Service/Spec/Provider/EmailGetSpecProvider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?php

/*
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC. All rights reserved. |
| |
| This work is published under the GNU AGPLv3 license with some |
| permitted exceptions and without any warranty. For full license |
| and copyright information, see https://civicrm.org/licensing |
+--------------------------------------------------------------------+
*/

namespace Civi\Api4\Service\Spec\Provider;

use Civi\Api4\Service\Spec\RequestSpec;

/**
* This applies to all entities with an email field.
*
* In the contact of "get", email validation doesn't make sense so change it to text.
*
* @service
* @internal
*/
class EmailGetSpecProvider extends \Civi\Core\Service\AutoService implements Generic\SpecProviderInterface {

/**
* @inheritDoc
*/
public function modifySpec(RequestSpec $spec) {
foreach ($spec->getFields() as $field) {
if ($field->getInputType() === 'Email') {
$field->setInputType('Text');
}
}
}

/**
* @inheritDoc
*/
public function applies($entity, $action) {
return $action === 'get';
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ abstract class AbstractRunAction extends \Civi\Api4\Generic\AbstractAction {
*/
private $entityActions;

private $editableInfo = [];

/**
* Override execute method to change the result object type
* @return \Civi\Api4\Result\SearchDisplayRunResult
Expand Down Expand Up @@ -814,17 +816,29 @@ private function fieldBelongsToEntity($entityName, $fieldName, $entityValues, $c
* @return array{entity: string, input_type: string, data_type: string, options: bool, serialize: bool, nullable: bool, fk_entity: string, value_key: string, value_path: string, id_key: string, id_path: string, explicit_join: string, grouping_fields: array}|null
*/
private function getEditableInfo($key) {
$result = NULL;
if (array_key_exists($key, $this->editableInfo)) {
return $this->editableInfo[$key];
}
// Strip pseudoconstant suffix
[$key] = explode(':', $key);
$field = $this->getField($key);
// If field is an implicit join to another entity (not a custom group), use the original fk field
if (!empty($field['implicit_join']) && empty($field['custom_field_id'])) {
return $this->getEditableInfo(substr($key, 0, -1 - strlen($field['name'])));
}
$result = NULL;
if ($field) {
// Reload field with correct action because `$this->getField()` uses 'get' as the action
// TODO: Load options if pseudoconstant is dynamic (`ControlField` present)
$createModeField = civicrm_api4($field['entity'], 'getFields', [
'where' => [['name', '=', $field['name']]],
'checkPermissions' => FALSE,
'action' => 'create',
])->first() ?? [];
// Merge with the augmented metadata like `explicit_join`
$field = $createModeField + $field;
$idKey = CoreUtil::getIdFieldName($field['entity']);
$path = ($field['explicit_join'] ? $field['explicit_join'] . '.' : '');
$path = (!empty($field['explicit_join']) ? $field['explicit_join'] . '.' : '');
$idPath = $path . $idKey;
// Hack to support editing relationships
if ($field['entity'] === 'RelationshipCache') {
Expand Down Expand Up @@ -855,7 +869,7 @@ private function getEditableInfo($key) {
}
}
}
return $result;
return $this->editableInfo[$key] = $result;
}

/**
Expand Down
11 changes: 11 additions & 0 deletions release-notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,17 @@ Other resources for identifying changes are:
* https://github.com/civicrm/civicrm-joomla
* https://github.com/civicrm/civicrm-wordpress

## CiviCRM 5.65.0

Released September 6, 2023

- **[Synopsis](release-notes/5.65.0.md#synopsis)**
- **[Features](release-notes/5.65.0.md#features)**
- **[Bugs resolved](release-notes/5.65.0.md#bugs)**
- **[Miscellany](release-notes/5.65.0.md#misc)**
- **[Credits](release-notes/5.65.0.md#credits)**
- **[Feedback](release-notes/5.65.0.md#feedback)**

## CiviCRM 5.64.0

Released August 2, 2023
Expand Down
Loading

0 comments on commit 44fa0ef

Please sign in to comment.