PartKeepr\UploadedFileBundle\EventListener\TemporaryFileEventListener::setReplacementFile PHP Method

setReplacementFile() protected method

Replaces the TemporaryUploadedFile or TempImage with the actual instance. Automatically sets the reference to the owning entity.
protected setReplacementFile ( string $targetEntity, TempUploadedFile | TempImage $source, object $target ) : object
$targetEntity string The entity to create
$source PartKeepr\UploadedFileBundle\Entity\TempUploadedFile | PartKeepr\ImageBundle\Entity\TempImage The source entity
$target object The entity where to set the property
return object The newly created object instance
    protected function setReplacementFile($targetEntity, $source, $target)
    {
        /**
         * @var UploadedFile
         */
        $newFile = new $targetEntity();
        $this->replaceFile($newFile, $source);
        $setterName = $this->getReferenceSetter($newFile, $target);
        if ($setterName !== false) {
            $this->propertyAccessor->setValue($newFile, $setterName, $target);
        }
        return $newFile;
    }