src/Request/ParamConverter/AuthorizeActionParamConverter.php
private function setPropertyValuesToObject(Request $request, $object, array $fields): void
    {
        $objectClass = get_class($object);

        foreach ($fields as $propertyName => $attributeName) {
            $value = $request->attributes->get($attributeName);
            $propertyTypes = $this->propertyTypeExtractor->getTypes($objectClass, $propertyName);
            $propertyType = null;

            if ($propertyTypes) {
                $propertyType = array_pop($propertyTypes);
            }

            if (!$value) {
                // The value is empty. Throw exception if value cannot be nullable.
                if ($propertyType && !$propertyType->isNullable()) {
                    throw new MissingAttributeException(sprintf(
                        'Missing the attribute with name "%s" in request.',
                        $attributeName
                    ));
                }

                // We cannot get the type of property or property can be nullable.
                continue;
            }

            if ($propertyType->getBuiltinType() === Type::BUILTIN_TYPE_OBJECT) {
                // The property should be an object. Try denormalize.
                $value = $this->denormalizer->denormalize($value, $propertyType->getClassName());
            }

            $refProperty = new \ReflectionProperty($object, $propertyName);
            $refProperty->setAccessible(true);
            $refProperty->setValue($object, $value);
        }
    }
private function setPropertyValuesToObject(Request $request, $object, array $fields): void
    {
        $objectClass = get_class($object);

        foreach ($fields as $propertyName => $attributeName) {
            $value = $request->attributes->get($attributeName);
            $propertyTypes = $this->propertyTypeExtractor->getTypes($objectClass, $propertyName);
            $propertyType = null;

            if ($propertyTypes) {
                $propertyType = array_pop($propertyTypes);
            }

            if (!$value) {
                // The value is empty. Throw exception if value cannot be nullable.
                if ($propertyType && !$propertyType->isNullable()) {
                    throw new MissingAttributeException(sprintf(
                        'Missing the attribute with name "%s" in request.',
                        $attributeName
                    ));
                }

                // We cannot get the type of property or property can be nullable.
                continue;
            }

            if ($propertyType->getBuiltinType() === Type::BUILTIN_TYPE_OBJECT) {
                // The property should be an object. Try denormalize.
                $value = $this->denormalizer->denormalize($value, $propertyType->getClassName());
            }

            $refProperty = new \ReflectionProperty($object, $propertyName);
            $refProperty->setAccessible(true);
            $refProperty->setValue($object, $value);
        }
    }
private function setPropertyValuesToObject ( Request $ request , $ object , array $ fields ) : void { $ objectClass = get_class ( $ object ) ; foreach ( $ fields as $ propertyName => $ attributeName ) { $ value = $ request -> attributes -> get ( $ attributeName ) ; $ propertyTypes = $ this -> propertyTypeExtractor -> getTypes ( $ objectClass , $ propertyName ) ; $ propertyType = null ; if ( $ propertyTypes ) { $ propertyType = array_pop ( $ propertyTypes ) ; } if ( ! $ value ) { // The value is empty. Throw exception if value cannot be nullable. if ( $ propertyType && ! $ propertyType -> isNullable ( ) ) { throw new MissingAttributeException ( sprintf ( 'Missing the attribute with name "%s" in request.' , $ attributeName ) ) ; } // We cannot get the type of property or property can be nullable. continue ; } if ( $ propertyType -> getBuiltinType ( ) === Type :: BUILTIN_TYPE_OBJECT ) { // The property should be an object. Try denormalize. $ value = $ this -> denormalizer -> denormalize ( $ value , $ propertyType -> getClassName ( ) ) ; } $ refProperty = new \ ReflectionProperty ( $ object , $ propertyName ) ; $ refProperty -> setAccessible ( true ) ; $ refProperty -> setValue ( $ object , $ value ) ; } }
Set the values to object

@param Request $request
@param object  $object
@param array   $fields

@throws MissingAttributeException
@throws \InvalidArgumentException
@throws \ReflectionException
Set the values to object