Skip to content

Commit

Permalink
Merge pull request #114 from TomHAnderson/hotfix/input-req-opt
Browse files Browse the repository at this point in the history
Fix for required and optional field mix
  • Loading branch information
TomHAnderson authored Jan 26, 2023
2 parents c0e8d5d + 5f488e6 commit 9729208
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/Input/InputFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function get(string $id, array $requiredFields = [], array $optionalField
* no reason to set or update an identifier. For the case where an identifier
* should be set or updated, this facotry is not the correct solution.
*/
if (! empty($optionalFields)) {
if (! empty($optionalFields) || ! empty($requiredFields)) {
// Include field as optional
if (in_array($fieldName, $optionalFields) || $optionalFields === ['*']) {
if ($optionalFields === ['*'] && $this->entityManager->getClassMetadata($id)->isIdentifier($fieldName)) {
Expand All @@ -61,8 +61,8 @@ public function get(string $id, array $requiredFields = [], array $optionalField
$fields[$fieldName]['description'] = $targetEntity->getMetadataConfig()['fields'][$fieldName]['description'];
$fields[$fieldName]['type'] = $this->typeManager->get($targetEntity->getMetadataConfig()['fields'][$fieldName]['type']);
}
} elseif (! empty($requiredFields)) {
// Include fields as required

// Include field as required
if (in_array($fieldName, $requiredFields) || $requiredFields === ['*']) {
if ($requiredFields === ['*'] && $this->entityManager->getClassMetadata($id)->isIdentifier($fieldName)) {
continue;
Expand Down

0 comments on commit 9729208

Please sign in to comment.