i have been learning zend framework for the past days now. I have encountered this error when i tried to run the site:
Annotation #ORM\PrePersist is not allowed to be declared on property Post\Entity\Post::$alterado. You may only use this annotation on these code elements: METHOD.
heres my Post.php file:
<?php
namespace Post\Entity;
use Application\Entity\AbstractEntity;
use Doctrine\ORM\Mapping as ORM;
/**
* Post
*
* #ORM\Table(name="post")
* #ORM\Entity
* #ORM\HasLifecycleCallbacks
* #ORM\Entity(repositoryClass="Post\Entity\PostRepository")
*/
class Post extends AbstractEntity
{
/**
* #var integer
* #ORM\Id
* #ORM\Column(name="id", type="integer", nullable=false)
*/
private $id;
/**
* #var string
*
* #ORM\Column(name="titulo", type="string", length=80, nullable=false)
*/
private $titulo;
/**
* #var string
*
* #ORM\Column(name="descricao", type="string", length=150, nullable=false)
*/
private $descricao;
/**
* #var string
*
* #ORM\Column(name="texto", type="text", nullable=false)
*/
private $texto;
/**
* #var \DateTime
*
* #ORM\Column(name="cadastro", type="datetime", nullable=false)
*/
private $cadastro;
/**
* #var \DateTime
* #ORM\PrePersist
* #ORM\Column(name="alterado", type="datetime", nullable=false)
*/
private $alterado;
/**
* #var boolean
* #ORM\PosUpdate
* #ORM\Column(name="ativo", type="boolean", nullable=false)
*/
private $ativo = '0';
/**
* #var \Categoria\Entity\Category
*
* #ORM\ManyToOne(targetEntity="Categoria\Entity\Category")
* #ORM\JoinColumn(name="categoria_id", referencedColumnName="id")
*/
private $categoriaId;
/**
* Set id
*
* #param integer $id
*
* #return Post
*/
public function setId($id)
{
$this->id = $id;
return $this;
}
/**
* Get id
*
* #return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set titulo
*
* #param string $titulo
*
* #return Post
*/
public function setTitulo($titulo)
{
$this->titulo = $titulo;
return $this;
}
/**
* Get titulo
*
* #return string
*/
public function getTitulo()
{
return $this->titulo;
}
/**
* Set descricao
*
* #param string $descricao
*
* #return Post
*/
public function setDescricao($descricao)
{
$this->descricao = $descricao;
return $this;
}
/**
* Get descricao
*
* #return string
*/
public function getDescricao()
{
return $this->descricao;
}
/**
* Set texto
*
* #param string $texto
*
* #return Post
*/
public function setTexto($texto)
{
$this->texto = $texto;
return $this;
}
/**
* Get texto
*
* #return string
*/
public function getTexto()
{
return $this->texto;
}
/**
* Set cadastro
*
* #param \DateTime $cadastro
*
* #return Post
*/
public function setCadastro($cadastro)
{
$this->cadastro = $cadastro;
return $this;
}
/**
* Get cadastro
*
* #return \DateTime
*/
public function getCadastro()
{
return $this->cadastro;
}
/**
* Set alterado
*
* #param \DateTime $alterado
*
* #return Post
*/
public function setAlterado($alterado)
{
$this->alterado = $alterado;
return $this;
}
/**
* Get alterado
*
* #return \DateTime
*/
public function getAlterado()
{
return $this->alterado;
}
/**
* Set ativo
*
* #param boolean $ativo
*
* #return Post
*/
public function setAtivo($ativo)
{
$this->ativo = $ativo;
return $this;
}
/**
* Get ativo
*
* #return boolean
*/
public function getAtivo()
{
return $this->ativo;
}
/**
* Set categoriaId
*
* #param \Categoria\Entity\Category $categoriaId
*
* #return Post
*/
public function setCategoriaId(\Categoria\Entity\Category $categoriaId = null)
{
$this->categoriaId = $categoriaId;
return $this;
}
/**
* Get categoriaId
*
* #return \Categoria\Entity\Category
*/
public function getCategoriaId()
{
return $this->categoriaId;
}
}
Am i missing any "use" statement on the file?
Any help is apreciated, thank you for your atention :)
I fixed it, i should have call #ORM\PrePersist and #ORM\PosUpdate on the method. :)
Related
When I try to get data like this, I got missing data:
$this->em->getRepository("PollBundle:Poll")->findAll();
Here are the results that I got: http://i.imgur.com/f0M54og.png
The system is getting poll's data however nothing to show about frequency as you can see. What's wrong?
PollFrequency Entity is like that as following:
namespace PollBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\ArrayCollection;
/**
* PollFrequency
*
* #ORM\Table(name="poll_frequency")
* #ORM\Entity
*/
class PollFrequency
{
/**
* #var integer
*
* #ORM\Column(name="id", type="integer")
* #ORM\Id
* #ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* #ORM\OneToMany(targetEntity="Poll", mappedBy="poll_frequency")
*/
private $polls;
/**
* #var string
* #ORM\Column(name="frequency", type="string")
*/
private $frequency;
/**
* #var string
* #ORM\Column(name="description", type="string")
*/
private $description;
public function __construct()
{
$this->polls = new ArrayCollection();
}
/**
* Get id
*
* #return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set frequency
*
* #param string $frequency
* #return PollFrequency
*/
public function setFrequency($frequency)
{
$this->frequency = $frequency;
return $this;
}
/**
* Get frequency
*
* #return string
*/
public function getFrequency()
{
return $this->frequency;
}
/**
* Set description
*
* #param string $description
* #return PollFrequency
*/
public function setDescription($description)
{
$this->description = $description;
return $this;
}
/**
* Get description
*
* #return string
*/
public function getDescription()
{
return $this->description;
}
/**
* Add polls
*
* #param \PollBundle\Entity\Poll $polls
* #return PollFrequency
*/
public function addPoll(\PollBundle\Entity\Poll $polls)
{
$this->polls[] = $polls;
return $this;
}
/**
* Remove polls
*
* #param \PollBundle\Entity\Poll $polls
*/
public function removePoll(\PollBundle\Entity\Poll $polls)
{
$this->polls->removeElement($polls);
}
/**
* Get polls
*
* #return \Doctrine\Common\Collections\Collection
*/
public function getPolls()
{
return $this->polls;
}
}
Poll Entity is also here as following:
<?php
namespace PollBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* Poll
*
* #ORM\Table(name="poll")
* #ORM\Entity
*/
class Poll
{
/**
* #var integer
*
* #ORM\Column(name="id", type="integer")
* #ORM\Id
* #ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* #var string
* #ORM\Column(name="name", type="string", nullable=false, length=255)
*/
private $name;
/**
* #var boolean
* #ORM\Column(name="pageload", nullable=false, type="boolean")
*/
private $pageload;
/**
* #var integer
* #ORM\Column(name="loadafter", nullable=false, type="integer")
*/
private $loadafter;
/**
* #var boolean
* #ORM\Column(name="exitload", nullable=false, type="boolean")
*/
private $exitload;
/**
* #var integer
* #ORM\Column(name="viewcount", nullable=false, type="integer")
*/
private $viewcount;
/**
* #var integer
* #ORM\Column(name="status", nullable=false, type="integer")
*/
private $status;
/**
* #var integer
* #ORM\Column(name="user_id", nullable=false, type="integer")
*/
private $user_id;
/**
* #ORM\OneToMany(targetEntity="PollFrequency", mappedBy="frequency")
* #ORM\JoinColumn(name="frequency_id", referencedColumnName="id")
*/
private $frequency;
/**
* #var \DateTime
* #ORM\Column(name="createdate", nullable=false, type="datetime")
*/
private $createdate;
/**
* Get id
*
* #return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set name
*
* #param string $name
* #return Poll
*/
public function setName($name)
{
$this->name = $name;
return $this;
}
/**
* Get name
*
* #return string
*/
public function getName()
{
return $this->name;
}
/**
* Set pageload
*
* #param boolean $pageload
* #return Poll
*/
public function setPageload($pageload)
{
$this->pageload = $pageload;
return $this;
}
/**
* Get pageload
*
* #return boolean
*/
public function getPageload()
{
return $this->pageload;
}
/**
* Set loadafter
*
* #param integer $loadafter
* #return Poll
*/
public function setLoadafter($loadafter)
{
$this->loadafter = $loadafter;
return $this;
}
/**
* Get loadafter
*
* #return integer
*/
public function getLoadafter()
{
return $this->loadafter;
}
/**
* Set exitload
*
* #param boolean $exitload
* #return Poll
*/
public function setExitload($exitload)
{
$this->exitload = $exitload;
return $this;
}
/**
* Get exitload
*
* #return boolean
*/
public function getExitload()
{
return $this->exitload;
}
/**
* Set viewcount
*
* #param integer $viewcount
* #return Poll
*/
public function setViewcount($viewcount)
{
$this->viewcount = $viewcount;
return $this;
}
/**
* Get viewcount
*
* #return integer
*/
public function getViewcount()
{
return $this->viewcount;
}
/**
* Set status
*
* #param integer $status
* #return Poll
*/
public function setStatus($status)
{
$this->status = $status;
return $this;
}
/**
* Get status
*
* #return integer
*/
public function getStatus()
{
return $this->status;
}
/**
* Set user_id
*
* #param integer $userId
* #return Poll
*/
public function setUserId($userId)
{
$this->user_id = $userId;
return $this;
}
/**
* Get user_id
*
* #return integer
*/
public function getUserId()
{
return $this->user_id;
}
/**
* Set createdate
*
* #param \DateTime $createdate
* #return Poll
*/
public function setCreatedate($createdate)
{
$this->createdate = $createdate;
return $this;
}
/**
* Get createdate
*
* #return \DateTime
*/
public function getCreatedate()
{
return $this->createdate;
}
/**
* Set frequency
*
* #param \PollBundle\Entity\PollFrequency $frequency
* #return Poll
*/
public function setFrequency(\PollBundle\Entity\PollFrequency $frequency = null)
{
$this->frequency = $frequency;
return $this;
}
/**
* Get frequency
*
* #return \PollBundle\Entity\PollFrequency
*/
public function getFrequency()
{
return $this->frequency;
}
}
Happy Coding to All !
I solved like that. If you need solution. that's it as following:
/**
* #ORM\ManyToOne(targetEntity="PollFrequency", fetch="EAGER")
* #ORM\JoinColumn(name="frequency_id", referencedColumnName="id")
*/
private $frequency;
And also I removed that part of PollFrequency as following:
/**
* #ORM\OneToMany(targetEntity="Poll", mappedBy="poll_frequency")
*/
private $polls;
and everything that related to $polls.
Happy Coding to All!
I am trying to populate my form with an List of Results from query with Doctrine
But i`m getting this error:
Catchable Fatal Error: Object of class AppBundle\Entity\Parceiros could not be converted to string
Here is my Form CoberturasType
namespace AppBundle\Form;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
class CoberturasType extends AbstractType
{
/**
* #param FormBuilderInterface $builder
* #param array $options
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('descricao')
->add('parceiro', EntityType::class, [
'class'=>'AppBundle:Parceiros',
])
;
}
/**
* #param OptionsResolver $resolver
*/
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults(array(
'data_class' => 'AppBundle\Entity\Coberturas'
));
}
}
Here is my CoberturasEntity
<?php
namespace AppBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* Coberturas
*
* #ORM\Table(name="coberturas")
* #ORM\Entity(repositoryClass="AppBundle\Repository\CoberturasRepository")
* #ORM\Entity()
* #ORM\HasLifecycleCallbacks()
*/
class Coberturas
{
/**
* #var int
*
* #ORM\Column(name="id", type="integer")
* #ORM\Id
* #ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* #ORM\ManyToOne(targetEntity="Parceiros")
* #ORM\JoinColumn(name="parceiro", referencedColumnName="id", nullable=false)
*/
protected $parceiro;
/**
* #var string
*
* #ORM\Column(name="descricao", type="string", length=120)
*/
private $descricao;
/**
* #var bool
*
* #ORM\Column(name="_ativo", type="boolean")
*/
private $ativo;
/**
* #var \DateTime
*
* #ORM\Column(name="created", type="datetime")
*/
private $created;
/**
* #var string
*
* #ORM\Column(name="updated", type="datetime")
*/
private $updated;
/**
* #var bool
*
* #ORM\Column(name="_deletado", type="boolean")
*/
private $deletado;
/**
* Get id
*
* #return int
*/
public function getId()
{
return $this->id;
}
/**
* Set descricao
*
* #param string $descricao
*
* #return Coberturas
*/
public function setDescricao($descricao)
{
$this->descricao = $descricao;
return $this;
}
/**
* Get descricao
*
* #return string
*/
public function getDescricao()
{
return $this->descricao;
}
/**
* Set ativo
*
* #param boolean $ativo
*
* #return Coberturas
*/
public function setAtivo($ativo)
{
$this->ativo = $ativo;
return $this;
}
/**
* Get ativo
*
* #return bool
*/
public function getAtivo()
{
return $this->ativo;
}
/**
* Set created
*
* #param \DateTime $created
*
* #return Coberturas
*/
public function setCreated($created)
{
$this->created = $created;
return $this;
}
/**
* Get created
*
* #return \DateTime
*/
public function getCreated()
{
return $this->created;
}
/**
* Set updated
*
* #param string $updated
*
* #return Coberturas
*/
public function setUpdated($updated)
{
$this->updated = $updated;
return $this;
}
/**
* Get updated
*
* #return string
*/
public function getUpdated()
{
return $this->updated;
}
/**
* Set deletado
*
* #param boolean $deletado
*
* #return Coberturas
*/
public function setDeletado($deletado)
{
$this->deletado = $deletado;
return $this;
}
/**
* Get deletado
*
* #return bool
*/
public function getDeletado()
{
return $this->deletado;
}
/**
* #ORM\PrePersist
*/
public function setCreatedValue()
{
$this->created = new \DateTime();
}
/**
* #ORM\postUpdate
*/
public function setUpdatedValue()
{
$this->updated = new \DateTime();
}
/**
* Set parceiro
*
* #param \AppBundle\Entity\Parceiros $parceiro
*
* #return Coberturas
*/
public function setParceiro(\AppBundle\Entity\Parceiros $parceiro = null)
{
$this->parceiro = $parceiro;
return $this;
}
/**
* Get parceiro
*
* #return \AppBundle\Entity\Parceiros
*/
public function getParceiro()
{
return $this->parceiro;
}
}
Here is my ParceirosEntity
<?php
namespace AppBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* Parceiros
*
* #ORM\Table(name="parceiros")
* #ORM\Entity(repositoryClass="AppBundle\Repository\ParceirosRepository")
* #ORM\Entity()
* #ORM\HasLifecycleCallbacks()
*/
class Parceiros
{
/**
* #var int
*
* #ORM\Column(name="id", type="integer")
* #ORM\Id
* #ORM\GeneratedValue(strategy="AUTO")
* #ORM\OneToMany(targetEntity="Coberturas", mappedBy="parceiro")
*/
private $id;
/**
* #var string
*
* #ORM\Column(name="razaoSocial", type="string", length=255)
*/
private $razaoSocial;
/**
* #var string
*
* #ORM\Column(name="nomeFantasia", type="string", length=255, nullable=true)
*/
private $nomeFantasia;
/**
* #var string
*
* #ORM\Column(name="cnpj", type="string", length=17, nullable=true)
*/
private $cnpj;
/**
* #var string
*
* #ORM\Column(name="inscEstadual", type="string", length=60, nullable=true)
*/
private $inscEstadual;
/**
* #var string
*
* #ORM\Column(name="cep", type="string", length=9, nullable=true)
*/
private $cep;
/**
* #var string
*
* #ORM\Column(name="endereco", type="string", length=160, nullable=true)
*/
private $endereco;
/**
* #var string
*
* #ORM\Column(name="numero", type="string", length=30, nullable=true)
*/
private $numero;
/**
* #var string
*
* #ORM\Column(name="complemento", type="string", length=30, nullable=true)
*/
private $complemento;
/**
* #var string
*
* #ORM\Column(name="bairro", type="string", length=80, nullable=true)
*/
private $bairro;
/**
* #var string
*
* #ORM\Column(name="cidade", type="string", length=100, nullable=true)
*/
private $cidade;
/**
* #var string
*
* #ORM\Column(name="estado", type="string", length=2, nullable=true)
*/
private $estado;
/**
* #var \DateTime
*
* #ORM\Column(name="created", type="datetime", nullable=true)
*/
private $created;
/**
* #var \DateTime
*
* #ORM\Column(name="updated", type="datetime", nullable=true)
*/
private $updated;
/**
* #var bool
*
* #ORM\Column(name="ativo", type="boolean", nullable=true)
*/
private $ativo = 1;
/**
* #var bool
*
* #ORM\Column(name="deletado", type="boolean", nullable=true)
*/
private $deletado = 0;
/**
* Get id
*
* #return int
*/
public function getId()
{
return $this->id;
}
/**
* Set razaoSocial
*
* #param string $razaoSocial
*
* #return Parceiros
*/
public function setRazaoSocial($razaoSocial)
{
$this->razaoSocial = $razaoSocial;
return $this;
}
/**
* Get razaoSocial
*
* #return string
*/
public function getRazaoSocial()
{
return $this->razaoSocial;
}
/**
* Set nomeFantasia
*
* #param string $nomeFantasia
*
* #return Parceiros
*/
public function setNomeFantasia($nomeFantasia)
{
$this->nomeFantasia = $nomeFantasia;
return $this;
}
/**
* Get nomeFantasia
*
* #return string
*/
public function getNomeFantasia()
{
return $this->nomeFantasia;
}
/**
* Set cnpj
*
* #param string $cnpj
*
* #return Parceiros
*/
public function setCnpj($cnpj)
{
$this->cnpj = $cnpj;
return $this;
}
/**
* Get cnpj
*
* #return string
*/
public function getCnpj()
{
return $this->cnpj;
}
/**
* Set inscEstadual
*
* #param string $inscEstadual
*
* #return Parceiros
*/
public function setInscEstadual($inscEstadual)
{
$this->inscEstadual = $inscEstadual;
return $this;
}
/**
* Get inscEstadual
*
* #return string
*/
public function getInscEstadual()
{
return $this->inscEstadual;
}
/**
* Set cep
*
* #param string $cep
*
* #return Parceiros
*/
public function setCep($cep)
{
$this->cep = $cep;
return $this;
}
/**
* Get cep
*
* #return string
*/
public function getCep()
{
return $this->cep;
}
/**
* Set endereco
*
* #param string $endereco
*
* #return Parceiros
*/
public function setEndereco($endereco)
{
$this->endereco = $endereco;
return $this;
}
/**
* Get endereco
*
* #return string
*/
public function getEndereco()
{
return $this->endereco;
}
/**
* Set numero
*
* #param string $numero
*
* #return Parceiros
*/
public function setNumero($numero)
{
$this->numero = $numero;
return $this;
}
/**
* Get numero
*
* #return string
*/
public function getNumero()
{
return $this->numero;
}
/**
* Set complemento
*
* #param string $complemento
*
* #return Parceiros
*/
public function setComplemento($complemento)
{
$this->complemento = $complemento;
return $this;
}
/**
* Get complemento
*
* #return string
*/
public function getComplemento()
{
return $this->complemento;
}
/**
* Set bairro
*
* #param string $bairro
*
* #return Parceiros
*/
public function setBairro($bairro)
{
$this->bairro = $bairro;
return $this;
}
/**
* Get bairro
*
* #return string
*/
public function getBairro()
{
return $this->bairro;
}
/**
* Set cidade
*
* #param string $cidade
*
* #return Parceiros
*/
public function setCidade($cidade)
{
$this->cidade = $cidade;
return $this;
}
/**
* Get cidade
*
* #return string
*/
public function getCidade()
{
return $this->cidade;
}
/**
* Set estado
*
* #param string $estado
*
* #return Parceiros
*/
public function setEstado($estado)
{
$this->estado = $estado;
return $this;
}
/**
* Get estado
*
* #return string
*/
public function getEstado()
{
return $this->estado;
}
/**
* Set created
*
* #param \DateTime $created
*
* #return Parceiros
*/
public function setCreated($created)
{
$this->created = $created;
return $this;
}
/**
* Get created
*
* #return \DateTime
*/
public function getCreated()
{
return $this->created;
}
/**
* Set updated
*
* #param \DateTime $updated
*
* #return Parceiros
*/
public function setUpdated($updated)
{
$this->updated = $updated;
return $this;
}
/**
* Get updated
*
* #return \DateTime
*/
public function getUpdated()
{
return $this->updated;
}
/**
* Set ativo
*
* #param boolean $ativo
*
* #return Parceiros
*/
public function setAtivo($ativo)
{
$this->ativo = $ativo;
return $this;
}
/**
* Get ativo
*
* #return bool
*/
public function getAtivo()
{
return $this->ativo;
}
/**
* Set deletado
*
* #param boolean $deletado
*
* #return Parceiros
*/
public function setDeletado($deletado)
{
$this->deletado = $deletado;
return $this;
}
/**
* Get deletado
*
* #return bool
*/
public function getDeletado()
{
return $this->deletado;
}
/**
* #ORM\PrePersist
*/
public function setCreatedValue()
{
$this->created = new \DateTime();
}
/**
* #ORM\postUpdate
*/
public function setUpdatedValue()
{
$this->updated = new \DateTime();
}
}
I just wanna show an SelectBox to user select for what "parceiro" he wanna insert a new "cobertura".
Thanks for the help...
I have 15 Entity Classes, and I want to put getEntityName static function in there but I don't want to make code duplication, and some of my entities extends vendor related class so I cannot put an abstract class to extend from these entities. I wanted to use traits.
<?php
namespace FrontendBundle\Traits\Entity;
trait GetEntityNameTrait {
public static function getEntityName()
{
return str_replace('\\', '\\\\', get_parent_class());
}
}
I use this trait in any of this entities, but I'm getting following compile error.
Compile Error: Cannot redeclare class FrontendBundle\Entity\Country
I tried several reflection methods all are the same result is this a bug or something is not logical ?
Others:
get_parent_class()
get_class()
get_called_class()
__CLASS__
<?php
namespace FrontendBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use FrontendBundle\EntityInterface;
use Symfony\Component\Validator\Constraints as Assert;
use FrontendBundle\Traits\Entity\GetEntityNameTrait;
/**
* Country
*
* #ORM\Table(name="country", uniqueConstraints={#ORM\UniqueConstraint(name="id_UNIQUE", columns={"id"}), #ORM\UniqueConstraint(name="iso_UNIQUE", columns={"iso"}), #ORM\UniqueConstraint(name="slug_tr_UNIQUE", columns={"slug_tr"}), #ORM\UniqueConstraint(name="slug_en_UNIQUE", columns={"slug_en"})})
* #ORM\Entity(repositoryClass="FrontendBundle\Repository\CountryRepository")
* #ORM\HasLifecycleCallbacks
*/
class Country implements EntityInterface
{
use GetEntityNameTrait;
/**
* #var integer
*
* #ORM\Column(name="id", type="integer", nullable=false)
* #ORM\Id
* #ORM\GeneratedValue(strategy="IDENTITY")
*/
private $id;
/**
* #var string
*
* #ORM\Column(name="iso", type="string", length=2, nullable=false)
*/
private $iso;
/**
* #var string
*
* #ORM\Column(name="iso3", type="string", length=3, nullable=true)
*/
private $iso3;
/**
* #var string
*
* #ORM\Column(name="currency_code", type="string", length=3, nullable=true)
*/
private $currencyCode;
/**
* #var string
*
* #ORM\Column(name="currency_name", type="string", length=20, nullable=true)
*/
private $currencyName;
/**
* #var string
*
* #ORM\Column(name="currency_symbol", type="string", length=5, nullable=true)
*/
private $currencySymbol;
/**
* #var string
*
* #ORM\Column(name="name_en", type="string", length=80, nullable=false)
*/
private $nameEn;
/**
* #var string
*
* #ORM\Column(name="name_tr", type="string", length=80, nullable=false)
*/
private $nameTr;
/**
* #var integer
*
* #ORM\Column(name="numcode", type="smallint", nullable=true)
*/
private $numcode;
/**
* #var integer
*
* #ORM\Column(name="phonecode", type="integer", nullable=false)
*/
private $phonecode;
/**
* #var float
*
* #ORM\Column(name="latitude", type="float", precision=18, scale=10, nullable=false)
*/
private $latitude;
/**
* #var float
*
* #ORM\Column(name="longitude", type="float", precision=18, scale=10, nullable=false)
*/
private $longitude;
/**
* #var string
*
* #ORM\Column(name="slug_en", type="string", length=50, nullable=false)
*/
private $slugEn;
/**
* #var string
*
* #ORM\Column(name="slug_tr", type="string", length=50, nullable=false)
*/
private $slugTr;
/**
* #var \DateTime
*
* #ORM\Column(name="created_at", type="datetime", nullable=false)
*/
private $createdAt;
/**
* #var \DateTime
*
* #ORM\Column(name="updated_at", type="datetime", nullable=false)
*/
private $updatedAt;
/**
* Get id
*
* #return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set iso
*
* #param string $iso
* #return Country
*/
public function setIso($iso)
{
$this->iso = $iso;
return $this;
}
/**
* Get iso
*
* #return string
*/
public function getIso()
{
return $this->iso;
}
/**
* Set iso3
*
* #param string $iso3
* #return Country
*/
public function setIso3($iso3)
{
$this->iso3 = $iso3;
return $this;
}
/**
* Get iso3
*
* #return string
*/
public function getIso3()
{
return $this->iso3;
}
/**
* Set currencyCode
*
* #param string $currencyCode
* #return Country
*/
public function setCurrencyCode($currencyCode)
{
$this->currencyCode = $currencyCode;
return $this;
}
/**
* Get currencyCode
*
* #return string
*/
public function getCurrencyCode()
{
return $this->currencyCode;
}
/**
* Set currencyName
*
* #param string $currencyName
* #return Country
*/
public function setCurrencyName($currencyName)
{
$this->currencyName = $currencyName;
return $this;
}
/**
* Get currencyName
*
* #return string
*/
public function getCurrencyName()
{
return $this->currencyName;
}
/**
* Set currencySymbol
*
* #param string $currencySymbol
* #return Country
*/
public function setCurrencySymbol($currencySymbol)
{
$this->currencySymbol = $currencySymbol;
return $this;
}
/**
* Get currencySymbol
*
* #return string
*/
public function getCurrencySymbol()
{
return $this->currencySymbol;
}
/**
* Set nameEn
*
* #param string $nameEn
* #return Country
*/
public function setNameEn($nameEn)
{
$this->nameEn = $nameEn;
return $this;
}
/**
* Get nameEn
*
* #return string
*/
public function getNameEn()
{
return $this->nameEn;
}
/**
* Set nameTr
*
* #param string $nameTr
* #return Country
*/
public function setNameTr($nameTr)
{
$this->nameTr = $nameTr;
return $this;
}
/**
* Get nameTr
*
* #return string
*/
public function getNameTr()
{
return $this->nameTr;
}
/**
* Set numcode
*
* #param integer $numcode
* #return Country
*/
public function setNumcode($numcode)
{
$this->numcode = $numcode;
return $this;
}
/**
* Get numcode
*
* #return integer
*/
public function getNumcode()
{
return $this->numcode;
}
/**
* Set phonecode
*
* #param integer $phonecode
* #return Country
*/
public function setPhonecode($phonecode)
{
$this->phonecode = $phonecode;
return $this;
}
/**
* Get phonecode
*
* #return integer
*/
public function getPhonecode()
{
return $this->phonecode;
}
/**
* Set latitude
*
* #param float $latitude
* #return Country
*/
public function setLatitude($latitude)
{
$this->latitude = $latitude;
return $this;
}
/**
* Get latitude
*
* #return float
*/
public function getLatitude()
{
return $this->latitude;
}
/**
* Set longitude
*
* #param float $longitude
* #return Country
*/
public function setLongitude($longitude)
{
$this->longitude = $longitude;
return $this;
}
/**
* Get longitude
*
* #return float
*/
public function getLongitude()
{
return $this->longitude;
}
/**
* Set slugEn
*
* #param string $slugEn
* #return Country
*/
public function setSlugEn($slugEn)
{
$this->slugEn = $slugEn;
return $this;
}
/**
* Get slugEn
*
* #return string
*/
public function getSlugEn()
{
return $this->slugEn;
}
/**
* Set slugTr
*
* #param string $slugTr
* #return Country
*/
public function setSlugTr($slugTr)
{
$this->slugTr = $slugTr;
return $this;
}
/**
* Get slugTr
*
* #return string
*/
public function getSlugTr()
{
return $this->slugTr;
}
/**
* Set createdAt
*
* #param \DateTime $createdAt
* #return Country
*/
public function setCreatedAt($createdAt)
{
$this->createdAt = $createdAt;
return $this;
}
/**
* Get createdAt
*
* #return \DateTime
*/
public function getCreatedAt()
{
return $this->createdAt;
}
/**
* Set updatedAt
*
* #param \DateTime $updatedAt
* #return Country
*/
public function setUpdatedAt($updatedAt)
{
$this->updatedAt = $updatedAt;
return $this;
}
/**
* Get updatedAt
*
* #return \DateTime
*/
public function getUpdatedAt()
{
return $this->updatedAt;
}
/**
*
* #ORM\PrePersist
* #ORM\PreUpdate
*/
public function updatedTimestamps()
{
$this->setUpdatedAt(new \DateTime('now'));
if ($this->getCreatedAt() == null) {
$this->setCreatedAt(new \DateTime('now'));
}
}
}
I have project which have different bundles. I want to create or divide entities in different bundle how can I create this. I am new in symfony please help me . I created but I can not do mapping correctly . a table which have primary key can't use in another bundle.
Here is my Entity
namespace DomainBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* WebsiteDomainConfigTest
*
* #ORM\Table(name="website_domain_config_test", indexes={#ORM\Index(name="fk_website_domain_config_test_1_idx", columns={"vendor_id"}), #ORM\Index(name="fk_website_domain_config_test_2_idx", columns={"country_id"})})
* #ORM\Entity
*/
class WebsiteDomainConfigTest
{
/**
* #var string
*
* #ORM\Column(name="domain", type="string", length=255, nullable=true)
*/
private $domain;
/**
* #var string
*
* #ORM\Column(name="vendor_code", type="string", length=15, nullable=true)
*/
private $vendorCode;
/**
* #var string
*
* #ORM\Column(name="domain_path", type="string", length=255, nullable=true)
*/
private $domainPath;
/**
* #var string
*
* #ORM\Column(name="assets_path", type="string", length=45, nullable=true)
*/
private $assetsPath;
/**
* #var string
*
* #ORM\Column(name="language", type="string", length=3, nullable=true)
*/
private $language;
/**
* #var string
*
* #ORM\Column(name="affiliate", type="string", length=25, nullable=true)
*/
private $affiliate;
/**
* #var string
*
* #ORM\Column(name="affiliate_logo", type="string", length=255, nullable=true)
*/
private $affiliateLogo;
/**
* #var string
*
* #ORM\Column(name="affiliate_address", type="string", length=255, nullable=true)
*/
private $affiliateAddress;
/**
* #var integer
*
* #ORM\Column(name="status", type="integer", nullable=true)
*/
private $status;
/**
* #var integer
*
* #ORM\Column(name="id", type="integer")
* #ORM\Id
* #ORM\GeneratedValue(strategy="IDENTITY")
*/
private $id;
/**
* #var \MobileSplash\SplashRequestBundle\Entity\Countries
*
* #ORM\ManyToOne(targetEntity="MobileSplash\SplashRequestBundle\Entity\Countries")
* #ORM\JoinColumns({
* #ORM\JoinColumn(name="country_id", referencedColumnName="id")
* })
*/
private $country;
/**
* #var \MobileSplash\SplashRequestBundle\Entity\Vendors
*
* #ORM\ManyToOne(targetEntity="MobileSplash\SplashRequestBundle\Entity\Vendors")
* #ORM\JoinColumns({
* #ORM\JoinColumn(name="vendor_id", referencedColumnName="id")
* })
*/
private $vendor;
/**
* Set domain
*
* #param string $domain
* #return WebsiteDomainConfigTest
*/
public function setDomain($domain)
{
$this->domain = $domain;
return $this;
}
/**
* Get domain
*
* #return string
*/
public function getDomain()
{
return $this->domain;
}
/**
* Set vendorCode
*
* #param string $vendorCode
* #return WebsiteDomainConfigTest
*/
public function setVendorCode($vendorCode)
{
$this->vendorCode = $vendorCode;
return $this;
}
/**
* Get vendorCode
*
* #return string
*/
public function getVendorCode()
{
return $this->vendorCode;
}
/**
* Set domainPath
*
* #param string $domainPath
* #return WebsiteDomainConfigTest
*/
public function setDomainPath($domainPath)
{
$this->domainPath = $domainPath;
return $this;
}
/**
* Get domainPath
*
* #return string
*/
public function getDomainPath()
{
return $this->domainPath;
}
/**
* Set assetsPath
*
* #param string $assetsPath
* #return WebsiteDomainConfigTest
*/
public function setAssetsPath($assetsPath)
{
$this->assetsPath = $assetsPath;
return $this;
}
/**
* Get assetsPath
*
* #return string
*/
public function getAssetsPath()
{
return $this->assetsPath;
}
/**
* Set language
*
* #param string $language
* #return WebsiteDomainConfigTest
*/
public function setLanguage($language)
{
$this->language = $language;
return $this;
}
/**
* Get language
*
* #return string
*/
public function getLanguage()
{
return $this->language;
}
/**
* Set affiliate
*
* #param string $affiliate
* #return WebsiteDomainConfigTest
*/
public function setAffiliate($affiliate)
{
$this->affiliate = $affiliate;
return $this;
}
/**
* Get affiliate
*
* #return string
*/
public function getAffiliate()
{
return $this->affiliate;
}
/**
* Set affiliateLogo
*
* #param string $affiliateLogo
* #return WebsiteDomainConfigTest
*/
public function setAffiliateLogo($affiliateLogo)
{
$this->affiliateLogo = $affiliateLogo;
return $this;
}
/**
* Get affiliateLogo
*
* #return string
*/
public function getAffiliateLogo()
{
return $this->affiliateLogo;
}
/**
* Set affiliateAddress
*
* #param string $affiliateAddress
* #return WebsiteDomainConfigTest
*/
public function setAffiliateAddress($affiliateAddress)
{
$this->affiliateAddress = $affiliateAddress;
return $this;
}
/**
* Get affiliateAddress
*
* #return string
*/
public function getAffiliateAddress()
{
return $this->affiliateAddress;
}
/**
* Set status
*
* #param integer $status
* #return WebsiteDomainConfigTest
*/
public function setStatus($status)
{
$this->status = $status;
return $this;
}
/**
* Get status
*
* #return integer
*/
public function getStatus()
{
return $this->status;
}
/**
* Get id
*
* #return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set country
*
* #param \MobileSplash\SplashRequestBundle\Entity\Countries $country
* #return WebsiteDomainConfigTest
*/
public function setCountry(\MobileSplash\SplashRequestBundle\Entity\Countries $country = null)
{
$this->country = $country;
return $this;
}
/**
* Get country
*
* #return \MobileSplash\SplashRequestBundle\Entity\Countries
*/
public function getCountry()
{
return $this->country;
}
/**
* Set vendor
*
* #param \MobileSplash\SplashRequestBundle\Entity\Vendors $vendor
* #return WebsiteDomainConfigTest
*/
public function setVendor(\MobileSplash\SplashRequestBundle\Entity\Vendors $vendor = null)
{
$this->vendor = $vendor;
return $this;
}
/**
* Get vendor
*
* #return \MobileSplash\SplashRequestBundle\Entity\Vendors
*/
public function getVendor()
{
return $this->vendor;
}
}
in your annotation use namespace like this:
targetEntity="\Mj\FooBundle\Entity\Foo"
I'm very new to Symfony 2.0 and doctrine. I have generete my entity refer to the cookbook 'How to Generate Entities from an Existing Database'
my relation ship :
client have many payement
payement to one client
Entity : Client.php
<?php
namespace Auto\EcoleBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* Client
*
* #ORM\Table(name="client", indexes={#ORM\Index(name="fk_client_delegation1_idx", columns={"delegation_id"})})
* #ORM\Entity
*/
class Client
{
/**
* #var string
*
* #ORM\Column(name="nom", type="string", length=45, nullable=false)
*/
private $nom;
/**
* #var \DateTime
*
* #ORM\Column(name="date_nais", type="date", nullable=true)
*/
private $dateNais;
/**
* #var string
*
* #ORM\Column(name="profession", type="string", length=45, nullable=true)
*/
private $profession;
/**
* #var string
*
* #ORM\Column(name="passport_num", type="string", length=45, nullable=true)
*/
private $passportNum;
/**
* #var string
*
* #ORM\Column(name="cin_num", type="string", length=45, nullable=true)
*/
private $cinNum;
/**
* #var \DateTime
*
* #ORM\Column(name="cin_date", type="date", nullable=true)
*/
private $cinDate;
/**
* #var string
*
* #ORM\Column(name="adresse", type="string", length=100, nullable=true)
*/
private $adresse;
/**
* #var string
*
* #ORM\Column(name="code_postal", type="string", length=45, nullable=true)
*/
private $codePostal;
/**
* #var boolean
*
* #ORM\Column(name="code", type="boolean", nullable=true)
*/
private $code;
/**
* #var string
*
* #ORM\Column(name="tel", type="string", length=45, nullable=true)
*/
private $tel;
/**
* #var string
*
* #ORM\Column(name="fax", type="string", length=45, nullable=true)
*/
private $fax;
/**
* #var string
*
* #ORM\Column(name="email", type="string", length=50, nullable=true)
*/
private $email;
/**
* #var integer
*
* #ORM\Column(name="id", type="integer")
* #ORM\Id
* #ORM\GeneratedValue(strategy="IDENTITY")
*/
private $id;
/**
* #var \Auto\EcoleBundle\Entity\Delegation
*
* #ORM\ManyToOne(targetEntity="Auto\EcoleBundle\Entity\Delegation")
* #ORM\JoinColumns({
* #ORM\JoinColumn(name="delegation_id", referencedColumnName="id")
* })
*/
private $delegation;
/**
* #var \Doctrine\Common\Collections\Collection
*
* #ORM\ManyToMany(targetEntity="Auto\EcoleBundle\Entity\ExamenCode", inversedBy="client")
* #ORM\JoinTable(name="client_has_examen_code",
* joinColumns={
* #ORM\JoinColumn(name="client_id", referencedColumnName="id")
* },
* inverseJoinColumns={
* #ORM\JoinColumn(name="examen_code_id", referencedColumnName="id")
* }
* )
*/
private $examenCode;
/**
* Constructor
*/
public function __construct()
{
$this->examenCode = new \Doctrine\Common\Collections\ArrayCollection();
}
/**
* Set nom
*
* #param string $nom
* #return Client
*/
public function setNom($nom)
{
$this->nom = $nom;
return $this;
}
/**
* Get nom
*
* #return string
*/
public function getNom()
{
return $this->nom;
}
/**
* Set dateNais
*
* #param \DateTime $dateNais
* #return Client
*/
public function setDateNais($dateNais)
{
$this->dateNais = $dateNais;
return $this;
}
/**
* Get dateNais
*
* #return \DateTime
*/
public function getDateNais()
{
return $this->dateNais;
}
/**
* Set profession
*
* #param string $profession
* #return Client
*/
public function setProfession($profession)
{
$this->profession = $profession;
return $this;
}
/**
* Get profession
*
* #return string
*/
public function getProfession()
{
return $this->profession;
}
/**
* Set passportNum
*
* #param string $passportNum
* #return Client
*/
public function setPassportNum($passportNum)
{
$this->passportNum = $passportNum;
return $this;
}
/**
* Get passportNum
*
* #return string
*/
public function getPassportNum()
{
return $this->passportNum;
}
/**
* Set cinNum
*
* #param string $cinNum
* #return Client
*/
public function setCinNum($cinNum)
{
$this->cinNum = $cinNum;
return $this;
}
/**
* Get cinNum
*
* #return string
*/
public function getCinNum()
{
return $this->cinNum;
}
/**
* Set cinDate
*
* #param \DateTime $cinDate
* #return Client
*/
public function setCinDate($cinDate)
{
$this->cinDate = $cinDate;
return $this;
}
/**
* Get cinDate
*
* #return \DateTime
*/
public function getCinDate()
{
return $this->cinDate;
}
/**
* Set adresse
*
* #param string $adresse
* #return Client
*/
public function setAdresse($adresse)
{
$this->adresse = $adresse;
return $this;
}
/**
* Get adresse
*
* #return string
*/
public function getAdresse()
{
return $this->adresse;
}
/**
* Set codePostal
*
* #param string $codePostal
* #return Client
*/
public function setCodePostal($codePostal)
{
$this->codePostal = $codePostal;
return $this;
}
/**
* Get codePostal
*
* #return string
*/
public function getCodePostal()
{
return $this->codePostal;
}
/**
* Set code
*
* #param boolean $code
* #return Client
*/
public function setCode($code)
{
$this->code = $code;
return $this;
}
/**
* Get code
*
* #return boolean
*/
public function getCode()
{
return $this->code;
}
/**
* Set tel
*
* #param string $tel
* #return Client
*/
public function setTel($tel)
{
$this->tel = $tel;
return $this;
}
/**
* Get tel
*
* #return string
*/
public function getTel()
{
return $this->tel;
}
/**
* Set fax
*
* #param string $fax
* #return Client
*/
public function setFax($fax)
{
$this->fax = $fax;
return $this;
}
/**
* Get fax
*
* #return string
*/
public function getFax()
{
return $this->fax;
}
/**
* Set email
*
* #param string $email
* #return Client
*/
public function setEmail($email)
{
$this->email = $email;
return $this;
}
/**
* Get email
*
* #return string
*/
public function getEmail()
{
return $this->email;
}
/**
* Get id
*
* #return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set delegation
*
* #param \Auto\EcoleBundle\Entity\Delegation $delegation
* #return Client
*/
public function setDelegation(\Auto\EcoleBundle\Entity\Delegation $delegation = null)
{
$this->delegation = $delegation;
return $this;
}
/**
* Get delegation
*
* #return \Auto\EcoleBundle\Entity\Delegation
*/
public function getDelegation()
{
return $this->delegation;
}
/**
* Add examenCode
*
* #param \Auto\EcoleBundle\Entity\ExamenCode $examenCode
* #return Client
*/
public function addExamenCode(\Auto\EcoleBundle\Entity\ExamenCode $examenCode)
{
$this->examenCode[] = $examenCode;
return $this;
}
/**
* Remove examenCode
*
* #param \Auto\EcoleBundle\Entity\ExamenCode $examenCode
*/
public function removeExamenCode(\Auto\EcoleBundle\Entity\ExamenCode $examenCode)
{
$this->examenCode->removeElement($examenCode);
}
/**
* Get examenCode
*
* #return \Doctrine\Common\Collections\Collection
*/
public function getExamenCode()
{
return $this->examenCode;
}
}
Entity :Payement.php
<?php
namespace Auto\EcoleBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* Payement
*
* #ORM\Table(name="payement", indexes={#ORM\Index(name="fk_payement_client1_idx", columns={"client_id"}), #ORM\Index(name="fk_payement_payement_type1_idx", columns={"payement_type_id"}), #ORM\Index(name="fk_payement_rebrique1_idx", columns={"rebrique_id"}), #ORM\Index(name="fk_payement_banque1_idx", columns={"banque_id"})})
* #ORM\Entity
*/
class Payement
{
/**
* #var float
*
* #ORM\Column(name="montant", type="float", precision=10, scale=0, nullable=true)
*/
private $montant;
/**
* #var \DateTime
*
* #ORM\Column(name="date_payement", type="date", nullable=true)
*/
private $datePayement;
/**
* #var string
*
* #ORM\Column(name="remarque", type="string", length=45, nullable=true)
*/
private $remarque;
/**
* #var string
*
* #ORM\Column(name="num_cheque", type="string", length=45, nullable=true)
*/
private $numCheque;
/**
* #var integer
*
* #ORM\Column(name="id", type="integer")
* #ORM\Id
* #ORM\GeneratedValue(strategy="IDENTITY")
*/
private $id;
/**
* #var \Auto\EcoleBundle\Entity\Banque
*
* #ORM\ManyToOne(targetEntity="Auto\EcoleBundle\Entity\Banque")
* #ORM\JoinColumns({
* #ORM\JoinColumn(name="banque_id", referencedColumnName="id")
* })
*/
private $banque;
/**
* #var \Auto\EcoleBundle\Entity\PayementRebrique
*
* #ORM\ManyToOne(targetEntity="Auto\EcoleBundle\Entity\PayementRebrique")
* #ORM\JoinColumns({
* #ORM\JoinColumn(name="rebrique_id", referencedColumnName="id")
* })
*/
private $rebrique;
/**
* #var \Auto\EcoleBundle\Entity\PayementType
*
* #ORM\ManyToOne(targetEntity="Auto\EcoleBundle\Entity\PayementType")
* #ORM\JoinColumns({
* #ORM\JoinColumn(name="payement_type_id", referencedColumnName="id")
* })
*/
private $payementType;
/**
* #var \Auto\EcoleBundle\Entity\Client
*
* #ORM\ManyToOne(targetEntity="Auto\EcoleBundle\Entity\Client")
* #ORM\JoinColumns({
* #ORM\JoinColumn(name="client_id", referencedColumnName="id")
* })
*/
private $client;
/**
* Set montant
*
* #param float $montant
* #return Payement
*/
public function setMontant($montant)
{
$this->montant = $montant;
return $this;
}
/**
* Get montant
*
* #return float
*/
public function getMontant()
{
return $this->montant;
}
/**
* Set datePayement
*
* #param \DateTime $datePayement
* #return Payement
*/
public function setDatePayement($datePayement)
{
$this->datePayement = $datePayement;
return $this;
}
/**
* Get datePayement
*
* #return \DateTime
*/
public function getDatePayement()
{
return $this->datePayement;
}
/**
* Set remarque
*
* #param string $remarque
* #return Payement
*/
public function setRemarque($remarque)
{
$this->remarque = $remarque;
return $this;
}
/**
* Get remarque
*
* #return string
*/
public function getRemarque()
{
return $this->remarque;
}
/**
* Set numCheque
*
* #param string $numCheque
* #return Payement
*/
public function setNumCheque($numCheque)
{
$this->numCheque = $numCheque;
return $this;
}
/**
* Get numCheque
*
* #return string
*/
public function getNumCheque()
{
return $this->numCheque;
}
/**
* Get id
*
* #return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set banque
*
* #param \Auto\EcoleBundle\Entity\Banque $banque
* #return Payement
*/
public function setBanque(\Auto\EcoleBundle\Entity\Banque $banque = null)
{
$this->banque = $banque;
return $this;
}
/**
* Get banque
*
* #return \Auto\EcoleBundle\Entity\Banque
*/
public function getBanque()
{
return $this->banque;
}
/**
* Set rebrique
*
* #param \Auto\EcoleBundle\Entity\PayementRebrique $rebrique
* #return Payement
*/
public function setRebrique(\Auto\EcoleBundle\Entity\PayementRebrique $rebrique = null)
{
$this->rebrique = $rebrique;
return $this;
}
/**
* Get rebrique
*
* #return \Auto\EcoleBundle\Entity\PayementRebrique
*/
public function getRebrique()
{
return $this->rebrique;
}
/**
* Set payementType
*
* #param \Auto\EcoleBundle\Entity\PayementType $payementType
* #return Payement
*/
public function setPayementType(\Auto\EcoleBundle\Entity\PayementType $payementType = null)
{
$this->payementType = $payementType;
return $this;
}
/**
* Get payementType
*
* #return \Auto\EcoleBundle\Entity\PayementType
*/
public function getPayementType()
{
return $this->payementType;
}
/**
* Set client
*
* #param \Auto\EcoleBundle\Entity\Client $client
* #return Payement
*/
public function setClient(\Auto\EcoleBundle\Entity\Client $client = null)
{
$this->client = $client;
return $this;
}
/**
* Get client
*
* #return \Auto\EcoleBundle\Entity\Client
*/
public function getClient()
{
return $this->client;
}
}
I want to use sonata_type_collection in my ClientAdmin:
After adding in Client.php
/**
* #ORM\OneToMany(targetEntity="Auto\EcoleBundle\Entity\Payement", cascade={"persist", "remove"}, mappedBy="client")
*
*/
private $payements;
and
$this->payements = new \Doctrine\Common\Collections\ArrayCollection(); in __constact() function
and updating Payement.php :
/**
* #var \Auto\EcoleBundle\Entity\Client
*
* #ORM\ManyToOne(targetEntity="Auto\EcoleBundle\Entity\Client", inversedBy="payements")
*/
private $client;
then after runing :
php app/console doctrine:generate:entities AutoEcoleBundle:Client
php app/console doctrine:generate:entities AutoEcoleBundle:Payement
to update my getting and setting
BUT the gets and sets of payement not generate in client class
Are you sure that's the right path to your entities ?
php app/console doctrine:generate:entities AutoEcoleBundle:Client
php app/console doctrine:generate:entities AutoEcoleBundle:Payement
You should get an error after those if it's not the right path.
Try adding the right one (Check it in your folders, not sure if it's right):
php app/console doctrine:generate:entities Auto\EcoleBundle\Entity\Client
php app/console doctrine:generate:entities Auto\EcoleBundle\Entity\Payement
resolved by running before generate entities
php app/console doctrine:cache:clear-metadata
any one can explain whay ?