UploadableFilePath field in entity definition is ignored (uploadable doctrine extensions)

271 Views Asked by At

Summary

My problem is connected with the fact that the entity field marked with @Gedmo\UploadableFilePath annotation is ignored by Symfony3. I am using the Uploadable behavior extension for Doctrine2.

CODE

In my entity I have:

/**
 * @ORM\Column
 * @Gedmo\UploadableFileName
 */
private $name;

/*
 * @ORM\Column
 * @Gedmo\UploadableFilePath
 */
 private $path;

SYMPTOMS

At first, I have noticed though that the path column is not generated in MySQL.

Then I found out that whenever I delete name field I get the following error:

[Gedmo\Exception\InvalidMappingException] Class "AppBundle\Entity\plik" must have an UploadableFilePath or Uploadable FileName field.

Documentation

In doctrine-uploadable documentation I see that:

@Gedmo\Mapping\Annotation\UploadableFilePath: This annotation is used to set which field will receive the path to the file. The field MUST be of type "string". Either this one or UploadableFileName annotation is REQUIRED to be set.

so it seems that I should be able to set $path field only.

Help request

Please advice why is UploadableFilePath field not being generated and why can't I delete the $name field?

1

There are 1 best solutions below

0
On BEST ANSWER

It seems that I have made a simple typo. There was lack of one * in the comment line.

/**
 * @ORM\Column
 * @Gedmo\UploadableFilePath
 */
 private $path;

It seems that symfony ignores annotations in such a case.