I have a class Printer
that uses a Trait
called TagTrait
.
I want to send a value from the class that uses that trait so that the trait defines a relation of a table in doctrine according to what interests me.
Example:
class Printer
{
use TagTrait; // aqui hacer algo para enviar el texto "printer"
// .. varios metodos
}
use Doctrine\ORM\Mapping as ORM;
trait TagTrait
{
/**
* @ORM\ManyToMany(targetEntity="Application\Sonata\ClassificationBundle\Entity\Tag", cascade={"persist"})
* @ORM\JoinTable(
* name= "Parametro_enviado_desde_clase",
* joinColumns={@ORM\JoinColumn(name=Parametro_enviado_desde_clase."_id", referencedColumnName="id")},
* inverseJoinColumns={@ORM\JoinColumn(name="tag_id", referencedColumnName="id")}
* )
*/
protected $tags;
// .. varios metodos
}
The idea is that the trait defines the property $tags
as a manytomany relation on another entity, but that the intermediate table has the name that I sent it from the trait.
If possible, this general type trait could be defined and I would only have to make a use indicating the parameter so that the doctrine will carry out its operations on the tables that interest me.
Does anyone know if something like this can be done?
The only solution I find is to remove all the code from the trait and put it in the entity printer, since I can not pass that parameter ...