Skip to content

Commit

Permalink
Fix Field definition for field not found if field name starts with up…
Browse files Browse the repository at this point in the history
…per case (#377)

* Fix Field definition for field not found if field name starts with upper case - resolves #369

* Apply php-cs-fixer changes

---------

Co-authored-by: dvesh3 <dvesh3@users.noreply.github.com>
  • Loading branch information
dvesh3 and dvesh3 authored Nov 9, 2023
1 parent 4e86244 commit 186a84f
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/Mapping/DataTarget/Direct.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,8 @@ protected function doAssignData($valueContainer, $fieldName, $data)
* @param string $getter
*
* @return bool
*
* @throws InvalidConfigurationException
*/
protected function checkAssignData($newData, $valueContainer, $getter)
{
Expand All @@ -138,7 +140,13 @@ protected function checkAssignData($newData, $valueContainer, $getter)
$currentData = $valueContainer->$getter($this->language);
DataObject::setHideUnpublished($hideUnpublished);

$fieldName = lcfirst(str_replace('get', '', $getter));
$fieldName = $this->fieldName;
//brick attribute
$fieldNameParts = explode('.', $this->fieldName);
if (count($fieldNameParts) === 3) {
$fieldName = $fieldNameParts[2];
}

$fieldDefinition = $this->getFieldDefinition($valueContainer, $fieldName);
if ($this->writeIfTargetIsNotEmpty === false && !$fieldDefinition->isEmpty($currentData)) {
return false;
Expand Down

0 comments on commit 186a84f

Please sign in to comment.