using reflection methods in traits - php

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'));
}
}
}

Related

Fill Selectbox with database data - Forms + Doctrine + Symfony 3

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...

symfony 2 how to create or map entity in different bundles

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"

Symfony 2 : doctrine entities not updated

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 ?

Entity class has no field or association named like in my DB

I want to create an request that recovers a number according to e.rules_id, e.status_id
public function findStat()
{
$types = $this->em
->getRepository('EthanRestBundle:EthanRules')
->createQueryBuilder('e')
->select('e.rules_id, e.status_id, COUNT(*)')
->groupBy('e.rules_id, e.status_id')
->orderBy('rules_id');
$types = $types->getQuery()->getSingleScalarResult();
return $types;
}
The error message:
[Semantical Error] line 0, col 9 near 'rules_id, e.status_id,': Error: Class Ethan\RestBundle\Entity\EthanRules has no field or association named rules_id"
I develop on Symfony 2 with FosrestBundle to create a REST Application
namespace Ethan\RestBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* EthanRules
*
* #ORM\Table(name="ethan_rules")
* #ORM\Entity
*/
class EthanRules
{
/**
* #var integer
*
* #ORM\Column(name="id", type="integer", nullable=false)
* #ORM\Id
* #ORM\GeneratedValue(strategy="IDENTITY")
*/
private $id;
/**
* #var string
*
* #ORM\Column(name="customer_key", type="string", length=45, nullable=false)
*/
private $customerKey;
/**
* #var string
*
* #ORM\Column(name="subscription_key", type="string", length=45, nullable=true)
*/
private $subscriptionKey;
/**
* #var string
*
* #ORM\Column(name="pole", type="string", length=45, nullable=false)
*/
private $pole;
/**
* #var string
*
* #ORM\Column(name="link_number", type="string", length=255, nullable=false)
*/
private $linkNumber;
/**
* #var string
*
* #ORM\Column(name="user", type="string", length=100, nullable=true)
*/
private $user;
/**
* #var \DateTime
*
* #ORM\Column(name="date_rdv", type="datetime", nullable=true)
*/
private $dateRdv;
/**
* #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;
/**
* #var \Rules
*
* #ORM\ManyToOne(targetEntity="Rules")
* #ORM\JoinColumns({
* #ORM\JoinColumn(name="rules_id", referencedColumnName="id")
* })
*/
private $rules;
/**
* #var \Status
*
* #ORM\ManyToOne(targetEntity="Status")
* #ORM\JoinColumns({
* #ORM\JoinColumn(name="status_id", referencedColumnName="id")
* })
*/
private $status;
public function _construct()
{
$this->createdAt = new \DateTime();
$this->createdAt->setTimestamp(time());
}
/**
* Get id
*
* #return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set customerKey
*
* #param string $customerKey
* #return EthanRules
*/
public function setCustomerKey($customerKey)
{
$this->customerKey = $customerKey;
return $this;
}
/**
* Get customerKey
*
* #return string
*/
public function getCustomerKey()
{
return $this->customerKey;
}
/**
* Set subscriptionKey
*
* #param string $subscriptionKey
* #return EthanRules
*/
public function setSubscriptionKey($subscriptionKey)
{
$this->subscriptionKey = $subscriptionKey;
return $this;
}
/**
* Get subscriptionKey
*
* #return string
*/
public function getSubscriptionKey()
{
return $this->subscriptionKey;
}
/**
* Set pole
*
* #param string $pole
* #return EthanRules
*/
public function setPole($pole)
{
$this->pole = $pole;
return $this;
}
/**
* Get pole
*
* #return string
*/
public function getPole()
{
return $this->pole;
}
/**
* Set linkNumber
*
* #param string $linkNumber
* #return EthanRules
*/
public function setLinkNumber($linkNumber)
{
$this->linkNumber = $linkNumber;
return $this;
}
/**
* Get linkNumber
*
* #return string
*/
public function getLinkNumber()
{
return $this->linkNumber;
}
/**
* Set user
*
* #param string $user
* #return EthanRules
*/
public function setUser($user)
{
$this->user = $user;
return $this;
}
/**
* Get user
*
* #return string
*/
public function getUser()
{
return $this->user;
}
/**
* Set dateRdv
*
* #param \DateTime $dateRdv
* #return EthanRules
*/
public function setDateRdv($dateRdv)
{
$this->dateRdv = $dateRdv;
return $this;
}
/**
* Get dateRdv
*
* #return \DateTime
*/
public function getDateRdv()
{
return $this->dateRdv;
}
/**
* Set createdAt
*
* #param \DateTime $createdAt
* #return EthanRules
*/
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 EthanRules
*/
public function setUpdatedAt($updatedAt)
{
$this->updatedAt = $updatedAt;
return $this;
}
/**
* Get updatedAt
*
* #return \DateTime
*/
public function getUpdatedAt()
{
return $this->updatedAt;
}
/**
* Set rules
*
* #param \Ethan\RestBundle\Entity\Rules $rules
* #return EthanRules
*/
public function setRules(\Ethan\RestBundle\Entity\Rules $rules = null)
{
$this->rules = $rules;
return $this;
}
/**
* Get rules
*
* #return \Ethan\RestBundle\Entity\Rules
*/
public function getRules()
{
return $this->rules;
}
/**
* Set status
*
* #param \Ethan\RestBundle\Entity\Status $status
* #return EthanRules
*/
public function setStatus(\Ethan\RestBundle\Entity\Status $status = null)
{
$this->status = $status;
return $this;
}
/**
* Get status
*
* #return \Ethan\RestBundle\Entity\Status
*/
public function getStatus()
{
return $this->status;
}
}
Since you have not defined a property $rules_id Doctrine can not select one. Instead join both entities and select their ids:
$types = $this->em
->getRepository('EthanRestBundle:EthanRules')
->createQueryBuilder('e')
->select('r.id AS rule_id, s.id AS status_id, COUNT(DISTINCT e.id)')
->leftJoin('e.rules', 'r')
->leftJoin('e.status', 's')
->groupBy('r.id, s.id')
->orderBy('r.id');
BUT: you use getSingleScalarResult() which will not work with multiple result rows!
Propably getArrayResult() will be best choice for you, since it looks like you don't want to work with objects.
Doctrine by default names all fields with camelCase in the entity classes but with_underscores in the Database.
You need to change your rules_id and status_id to rules and status accordingly.

Symfony2, doctrine limit and offset doesn't work as expected

I'm trying to get results from my table using limit and offsett from my table, and this table has a relations with another two tables.. one of them is MayToOne and the other is OneToOne
If I don't use setFirstResult and setMaxResults the results are the expected because return the information of my table and the information of the other tables related but using setFirst.. and setMax.. only return the information of the table and not the information of the tables related.
$query = $this->repository->createQueryBuilder('p')
->where('LOWER(p.name) LIKE LOWER(:term)')
->orWhere('LOWER(p.summary) LIKE LOWER(:term)')
->orwhere('LOWER(p.description) LIKE LOWER(:term)')
->setParameter('term', '%'.$parameters['term'].'%')
->setFirstResult($offset)
->setMaxResults($limit)
->orderBy('p.id','DESC')
->getQuery();
$attractions = $query->getResult();
And I'm trying with paginator using this query:
$query = $this->repository->createQueryBuilder('p')
->where('LOWER(p.name) LIKE LOWER(:term)')
->orWhere('LOWER(p.summary) LIKE LOWER(:term)')
->orwhere('LOWER(p.description) LIKE LOWER(:term)')
->setParameter('term', '%'.$parameters['term'].'%')
->setFirstResult($offset)
->setMaxResults($limit)
->orderBy('p.id','DESC');
$attractions = new Paginator($query, $fetchJoinCollection = true);
But is not working because appear this error:
[Semantical Error] The annotation "#Enum" in property Doctrine\ORM\Mapping\GeneratedValue::$strategy was never imported. Did you maybe forget to add a "use" statement for this annotation?
Entity
<?php
namespace Acme\MyBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use Acme\MyBundle\Model\AttractionInterface;
use Gedmo\Mapping\Annotation as Gedmo;
use JMS\Serializer\Annotation\ExclusionPolicy;
use JMS\Serializer\Annotation\Exclude;
use JMS\Serializer\Annotation\Expose;
use JMS\Serializer;
/**
* Attraction
*
* #ORM\Table(name="attractions")
* #ORM\Entity
*
* #ExclusionPolicy("all")
*/
class Attraction implements AttractionInterface
{
/**
* #var integer
*
* #ORM\Column(name="id", type="integer")
* #ORM\Id
* #ORM\GeneratedValue(strategy="AUTO")
* #Expose
*/
private $id;
/**
* #var string
*
* #ORM\Column(name="name", type="string", length=150, nullable=false)
* #Expose
*/
private $name;
/**
* #var string
*
* #ORM\Column(name="latitude", type="string", length=30, nullable=false)
* #Expose
*/
private $latitude;
/**
* #var string
*
* #ORM\Column(name="longitude", type="string", length=30, nullable=false)
* #Expose
*/
private $longitude;
/**
* #var string
*
* #ORM\Column(name="summary", type="text", nullable=false)
* #Expose
*/
private $summary;
/**
* #var string
*
* #ORM\Column(name="description", type="text", nullable=true)
* #Expose
*/
private $description;
/**
* #var integer
*
* #ORM\Column(name="available_places", type="smallint")
* #Expose
*/
private $availablePlaces;
/**
* #var float
*
* #ORM\Column(name="original_price", type="float", nullable=false)
* #Expose
*/
private $originalPrice;
/**
* #var float
*
* #ORM\Column(name="new_price", type="float", nullable=false)
* #Expose
*/
private $newPrice;
/**
* #var \DateTime
*
* #ORM\Column(name="starting_point", type="datetime", nullable=false)
* #Expose
*/
private $startingPoint;
/**
* #var string
*
* #ORM\Column(name="picture", type="string", length=50, nullable=false)
* #Expose
*/
private $picture;
/**
* #var integer
*
* #ORM\ManyToOne(targetEntity="Vendor")
* #ORM\JoinColumn(name="vendor", referencedColumnName="id")
* #Expose
*/
private $vendor;
/**
* #var integer
*
* #ORM\OneToOne(targetEntity="Category")
* #ORM\JoinColumn(name="category", referencedColumnName="id")
* #Expose
*/
private $category;
/**
* #var \DateTime
*
* #ORM\Column(name="created_at", type="datetime", options={"default" = "CURRENT_TIMESTAMP"}, nullable=true)
* #Gedmo\Timestampable(on="create")
* #Expose
*/
private $createdAt;
/**
* #var \DateTime
*
* #ORM\Column(name="updated_at", type="datetime", options={"default" = "CURRENT_TIMESTAMP"}, nullable=true)
* #Expose
*/
private $updatedAt;
public function __toString()
{
return $this->name;
}
/**
* Get id
*
* #return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set name
*
* #param string $name
* #return Attraction
*/
public function setName($name)
{
$this->name = $name;
return $this;
}
/**
* Get name
*
* #return string
*/
public function getName()
{
return $this->name;
}
/**
* Set latitude
*
* #param string $latitude
* #return Attraction
*/
public function setLatitude($latitude)
{
$this->latitude = $latitude;
return $this;
}
/**
* Get latitude
*
* #return string
*/
public function getLatitude()
{
return $this->latitude;
}
/**
* Set longitude
*
* #param string $longitude
* #return Attraction
*/
public function setLongitude($longitude)
{
$this->longitude = $longitude;
return $this;
}
/**
* Get longitude
*
* #return string
*/
public function getLongitude()
{
return $this->longitude;
}
/**
* Set summary
*
* #param string $summary
* #return Attraction
*/
public function setSummary($summary)
{
$this->summary = $summary;
return $this;
}
/**
* Get summary
*
* #return string
*/
public function getSummary()
{
return $this->summary;
}
/**
* Set description
*
* #param string $description
* #return Attraction
*/
public function setDescription($description)
{
$this->description = $description;
return $this;
}
/**
* Get description
*
* #return string
*/
public function getDescription()
{
return $this->description;
}
/**
* Set availablePlaces
*
* #param integer $availablePlaces
* #return Attraction
*/
public function setAvailablePlaces($availablePlaces)
{
$this->availablePlaces = $availablePlaces;
return $this;
}
/**
* Get availablePlaces
*
* #return integer
*/
public function getAvailablePlaces()
{
return $this->availablePlaces;
}
/**
* Set originalPrice
*
* #param float $originalPrice
* #return Attraction
*/
public function setOriginalPrice($originalPrice)
{
$this->originalPrice = $originalPrice;
return $this;
}
/**
* Get originalPrice
*
* #return float
*/
public function getOriginalPrice()
{
return $this->originalPrice;
}
/**
* Set newPrice
*
* #param float $newPrice
* #return Attraction
*/
public function setNewPrice($newPrice)
{
$this->newPrice = $newPrice;
return $this;
}
/**
* Get newPrice
*
* #return float
*/
public function getNewPrice()
{
return $this->newPrice;
}
/**
* Set startingPoint
*
* #param \DateTime $startingPoint
* #return Attraction
*/
public function setStartingPoint($startingPoint)
{
$this->startingPoint = \DateTime::createFromFormat('Y-m-d H:i:s', $startingPoint);
return $this;
}
/**
* Get startingPoint
*
* #return \DateTime
*/
public function getStartingPoint()
{
return $this->startingPoint;
}
/**
* Set picture
*
* #param string $picture
* #return Attraction
*/
public function setPicture($picture)
{
$this->picture = $picture;
return $this;
}
/**
* Get picture
*
* #return string
*/
public function getPicture()
{
return $this->picture;
}
/**
* Set vendor
*
* #param integer $vendor
* #return Attraction
*/
public function setVendor($vendor)
{
$this->vendor = $vendor;
return $this;
}
/**
* Get vendor
*
* #return integer
*/
public function getVendor()
{
return $this->vendor;
}
/**
* Set category
*
* #param integer $category
* #return Attraction
*/
public function setCategory($category)
{
$this->category = $category;
return $this;
}
/**
* Get categoryId
*
* #return integer
*/
public function getCategory()
{
return $this->category;
}
/**
* Set createdAt
*
* #param \DateTime $createdAt
* #return Attraction
*/
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 Attraction
*/
public function setUpdatedAt($updatedAt)
{
$this->updatedAt = $updatedAt;
return $this;
}
/**
* Get updatedAt
*
* #return \DateTime
*/
public function getUpdatedAt()
{
return $this->updatedAt;
}
}
have you seen https://github.com/schmittjoh/JMSSerializerBundle/issues/380 ?
it seems having the same issue.
a question: doe it work without that complex query? for example with something like:
$query = $this->repository->createQueryBuilder('p')
->orderBy('p.id','DESC')
->getQuery();
$attractions = $query->getResult();

Categories