private function getField(array $payload, array $data, string $propertyName)
    {
        $isField = false;
        $payload = json_decode(json_encode($payload), true);
        if ($payload['items'] && \is_array($payload['items']) && \count($payload['items']) > 0) {
            foreach ($payload['items'] as $item) {
                if (isset($item['data'][$propertyName]) && $item['data'][$propertyName]) {
                    $isField = $item['data']['name'];
                }
            }
        }

        return $isField ? $data[$isField] : null;
    }
private function getField(array $payload, array $data, string $propertyName)
    {
        $isField = false;
        $payload = json_decode(json_encode($payload), true);
        if ($payload['items'] && \is_array($payload['items']) && \count($payload['items']) > 0) {
            foreach ($payload['items'] as $item) {
                if (isset($item['data'][$propertyName]) && $item['data'][$propertyName]) {
                    $isField = $item['data']['name'];
                }
            }
        }

        return $isField ? $data[$isField] : null;
    }
private function getField ( array $ payload , array $ data , string $ propertyName ) { $ isField = false ; $ payload = json_decode ( json_encode ( $ payload ) , true ) ; if ( $ payload [ 'items' ] && \ is_array ( $ payload [ 'items' ] ) && \ count ( $ payload [ 'items' ] ) > 0 ) { foreach ( $ payload [ 'items' ] as $ item ) { if ( isset ( $ item [ 'data' ] [ $ propertyName ] ) && $ item [ 'data' ] [ $ propertyName ] ) { $ isField = $ item [ 'data' ] [ 'name' ] ; } } } return $ isField ? $ data [ $ isField ] : null ; }
Check the aggregate for a field with the propertyName boolean
property and return the fields value.

Example: You have a field with a "replyTo" boolean and want to return
its value when it is set to true.

Todo: Support child items.

@param array  $payload
@param array  $data
@param string $propertyName

@return mixed|null
Check the aggregate for a field with the propertyName boolean property and return the fields value .