public function convertFrom($source, $targetType, array $convertedChildProperties = [], PropertyMappingConfigurationInterface $configuration = null)
    {
        if (empty($source)) {
            return null;
        }

        if ($source instanceof UploadedFileInterface) {
            return $this->handleUploadedFile($source, $configuration);
        }

        if (is_string($source)) {
            $source = ['hash' => $source];
        }

        // $source is ALWAYS an array at this point
        if (isset($source['error']) || isset($source['originallySubmittedResource'])) {
            return $this->handleFileUploads($source, $configuration);
        } elseif (isset($source['hash']) || isset($source['data'])) {
            return $this->handleHashAndData($source, $configuration);
        }
        return null;
    }
public function convertFrom($source, $targetType, array $convertedChildProperties = [], PropertyMappingConfigurationInterface $configuration = null)
    {
        if (empty($source)) {
            return null;
        }

        if ($source instanceof UploadedFileInterface) {
            return $this->handleUploadedFile($source, $configuration);
        }

        if (is_string($source)) {
            $source = ['hash' => $source];
        }

        // $source is ALWAYS an array at this point
        if (isset($source['error']) || isset($source['originallySubmittedResource'])) {
            return $this->handleFileUploads($source, $configuration);
        } elseif (isset($source['hash']) || isset($source['data'])) {
            return $this->handleHashAndData($source, $configuration);
        }
        return null;
    }
public function convertFrom ( $ source , $ targetType , array $ convertedChildProperties = [ ] , PropertyMappingConfigurationInterface $ configuration = null ) { if ( empty ( $ source ) ) { return null ; } if ( $ source instanceof UploadedFileInterface ) { return $ this -> handleUploadedFile ( $ source , $ configuration ) ; } if ( is_string ( $ source ) ) { $ source = [ 'hash' => $ source ] ; } // $source is ALWAYS an array at this point if ( isset ( $ source [ 'error' ] ) || isset ( $ source [ 'originallySubmittedResource' ] ) ) { return $ this -> handleFileUploads ( $ source , $ configuration ) ; } elseif ( isset ( $ source [ 'hash' ] ) || isset ( $ source [ 'data' ] ) ) { return $ this -> handleHashAndData ( $ source , $ configuration ) ; } return null ; }
Converts the given string or array to a PersistentResource object.

If the input format is an array, this method assumes the resource to be a
fresh file upload and imports the temporary upload file through the
ResourceManager.

Note that $source['error'] will also be present if a file was successfully
uploaded. In that case its value will be \UPLOAD_ERR_OK.

@param array $source The upload info (expected keys: error, name, tmp_name)
@param string $targetType
@param array $convertedChildProperties
@param PropertyMappingConfigurationInterface $configuration
@return PersistentResource|FlowError if the input format is not supported or could not be converted for other reasons
@throws Exception
@throws Exception\InvalidResourceDataException
@throws InvalidPropertyMappingConfigurationException
Converts the given string or array to a PersistentResource object .