DoctrineExtensions icon indicating copy to clipboard operation
DoctrineExtensions copied to clipboard

Uploadable not working for ODM

Open spin7ion opened this issue 2 years ago • 1 comments

Hello,

If you are using ODM, you can't use UploadableFileSize because of error: Field "size" to work as an "UploadableFileSize" field must be of one of the following types: "decimal".

If you check Gedmo\Uploadable\Mapping\Validator.php you can see, that variable $validFileSizeTypesODM have no usages.

From Validator.php: /** * @param string $field * * @return void */ public static function validateFileSizeField(ClassMetadata $meta, $field) { self::validateField($meta, $field, self::UPLOADABLE_FILE_SIZE, self::$validFileSizeTypes); }

You should check for if you are in ODM or ORM. Can you fix it or tell, how to do it?

spin7ion avatar Jul 15 '22 23:07 spin7ion

Hi @spin7ion, apparently there is no support for ODM in Uploadable extension, I haven't used it so I'm not sure how hard would be to make it compatible with both ORM and ODM.

For this specific case, you could add float to $validFileSizeTypes, I think that's the way it's done in other extensions, but you will need to change more things apart from the Validator.

franmomu avatar Jul 16 '22 17:07 franmomu

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

github-actions[bot] avatar Jan 18 '23 12:01 github-actions[bot]