I'm getting this error on my production environnent: (from prod.log)
[2012-01-30 17:00:51] request.CRITICAL: Doctrine\ORM\Mapping\MappingException: Class Gitek\UdaBundle\Entity\Curso is not a valid entity or mapped super class. (uncaught exception) at /home/uda/shared/vendor/doctrine/lib/Doctrine/ORM/Mapping/MappingException.php line 142 [] []
But in my development environnent everything works fine.
And this is my Curso entity:
<?php
namespace Gitek\UdaBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
/**
* Gitek\UdaBundle\Entity\Curso
*
* #ORM\Table(name="Curso")
* #ORM\HasLifecycleCallbacks
* #ORM\Entity(repositoryClass="Gitek\UdaBundle\Entity\CursoRepository")
*/
class Curso
{
/**
* #var integer $id
*
* #ORM\Column(name="id", type="integer")
* #ORM\Id
* #ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* #var string $nombre
*
* #ORM\Column(name="nombre", type="string", length=255)
*/
private $nombre;
/**
* #var string $version
*
* #ORM\Column(name="version", type="string", length=255, nullable=true)
*/
private $version;
/**
* #var integer $orden
*
* #ORM\Column(name="orden", type="integer", nullable=true, nullable=true)
*/
private $orden;
/**
* #var integer $tiempo
*
* #ORM\Column(name="tiempo", type="integer", nullable=true, nullable=true)
*/
private $tiempo;
/**
* #ORM\OneToMany(targetEntity="Detcurso", mappedBy="curso", cascade={"remove"})
* #ORM\OrderBy({"orden" = "ASC"})
*/
private $detcursos;
/**
* #ORM\OneToMany(targetEntity="Historial", mappedBy="curso", cascade={"remove"})
*/
private $historiales;
/**
* #ORM\Column(type="datetime")
*/
protected $created;
/**
* #ORM\Column(type="datetime")
*/
protected $updated;
public function __construct()
{
$this->detcursos = new \Doctrine\Common\Collections\ArrayCollection();
$this->setCreated(new \DateTime());
$this->setUpdated(new \DateTime());
}
public function __toString()
{
return $this->getNombre();
}
/**
* Get id
*
* #return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set nombre
*
* #param string $nombre
*/
public function setNombre($nombre)
{
$this->nombre = $nombre;
}
/**
* Get nombre
*
* #return string
*/
public function getNombre()
{
return $this->nombre;
}
/**
* Set version
*
* #param string $version
*/
public function setVersion($version)
{
$this->version = $version;
}
/**
* Get version
*
* #return string
*/
public function getVersion()
{
return $this->version;
}
/**
* Set orden
*
* #param integer $orden
*/
public function setOrden($orden)
{
$this->orden = $orden;
}
/**
* Get orden
*
* #return integer
*/
public function getOrden()
{
return $this->orden;
}
/**
* Set created
*
* #param datetime $created
*/
public function setCreated($created)
{
$this->created = $created;
}
/**
* Get created
*
* #return datetime
*/
public function getCreated()
{
return $this->created;
}
/**
* Set updated
*
* #param datetime $updated
*/
public function setUpdated($updated)
{
$this->updated = $updated;
}
/**
* Get updated
*
* #return datetime
*/
public function getUpdated()
{
return $this->updated;
}
/**
* Add detcursos
*
* #param Gitek\UdaBundle\Entity\Detcurso $detcursos
*/
public function addDetcurso(\Gitek\UdaBundle\Entity\Detcurso $detcursos)
{
$this->detcursos[] = $detcursos;
}
/**
* Get detcursos
*
* #return Doctrine\Common\Collections\Collection
*/
public function getDetcursos()
{
return $this->detcursos;
}
/**
* Add historiales
*
* #param Gitek\UdaBundle\Entity\Historial $historiales
*/
public function addHistorial(\Gitek\UdaBundle\Entity\Historial $historiales)
{
$this->historiales[] = $historiales;
}
/**
* Get historiales
*
* #return Doctrine\Common\Collections\Collection
*/
public function getHistoriales()
{
return $this->historiales;
}
/**
* Get historial
*
* #return Doctrine\Common\Collections\Collection
*/
public function getHistorial()
{
return $this->historial;
}
/**
* Set tiempo
*
* #param integer $tiempo
*/
public function setTiempo($tiempo)
{
$this->tiempo = $tiempo;
}
/**
* Get tiempo
*
* #return integer
*/
public function getTiempo()
{
return $this->tiempo;
}
}
As I said, in app_dev works correctly.
You can have different metadata cache configurations depending on which environment you are in. For example apc can cause troubles if not correctly refreshed.
Anyway, you will have to warmup your cache in prod environment, like this:
php app/console cache:clear --env=prod
If this still doesn't work, try to change your doctrine cache configuration:
orm:
auto_generate_proxy_classes: false
default_entity_manager: default
entity_managers:
default:
metadata_cache_driver: array
query_cache_driver: array
result_cache_driver: array
This will use the array cache driver, which is refreshed once at every request.
You shouldn't use this in production, but it can help you to understand where you problem comes from.
In my case the problem was solved by changing my servers cache from eAccelerator to APC. Apparently eAccelerator strips all the comments from files which breaks your annotations.
Related
First, I'm a french beginner in Symfony4,
Second, I already searched in Symfony Documentation, asked some friends, called my mom..
I'm working on EasyAdminBundle on the form Edit / New Entity.
I have to change the label of my entities but when I do it, my form type is changing.
Here's when picture of my view before editing:
I want to change ' id_equipe' to 'Domicile (home for english )' and id_equipe_equipes to 'exterieur (Visitors)'
So when I tried this :
fields:
- { property: 'id_equipe', label: equipe_domicile}
- { property: 'id_equipe_equipes', label: equipe_extérieur}
The type of the properties is changing to TextArea and I don't know why.
I tried to put a new type like this :
- { property: 'id_equipe', label: equipe_domicile, type: 'choice'}
but my select is blank, I cannot choose anything.
This is what I get:
Thanks you guys
Ps: sorry for ten years old english
So, look, if I understand correctly - id_equipe is a key to external entity. So, this way, to get it worked - you need to use type: 'entity' and also add type_options option, something like that:
- { property: 'id_equipe', label: 'Domicile', type: 'entity', type_options: { class: 'App\Entity\Equipe', multiple: true } }
UPDATE:
So, due to discussion found that the problem was in the property naming. Right to be property: 'idEquipe' not property: 'id_equipe'. So the property names must be same as in the entity, not as the name of the field in the database.
Here's my Matchs entity.
<?php
namespace App\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
/**
* Matchs
*
* #ORM\Table(name="matchs", indexes={#ORM\Index(name="MATCHS_EQUIPES1_FK", columns={"ID_EQUIPE_EQUIPES"}), #ORM\Index(name="MATCHS_EQUIPES_FK", columns={"ID_EQUIPE"}), #ORM\Index(name="MATCHS_JOURNEE0_FK", columns={"ID_JOURNEE"})})
* #ORM\Entity
*/
class Matchs
{
/**
* #var int
*
* #ORM\Column(name="ID_MATCHS", type="integer", nullable=false)
* #ORM\Id
* #ORM\GeneratedValue(strategy="IDENTITY")
*/
private $idMatchs;
/**
* #var \DateTime
*
* #ORM\Column(name="DATE_MATCHS", type="datetime", nullable=false)
*/
private $dateMatchs;
/**
* #var string|null
*
* #ORM\Column(name="RESUME_MATCHS", type="text", length=65535, nullable=true)
*/
private $resumeMatchs;
/**
* #var string|null
*
* #ORM\Column(name="TITRE_MATCH", type="string", length=255, nullable=true)
*/
private $titreMatch;
/**
* #var int
*
* #ORM\Column(name="SCORE_EQUIPE1", type="integer", nullable=false)
*/
private $scoreEquipe1;
/**
* #var int
*
* #ORM\Column(name="SCORE_EQUIPE2", type="integer", nullable=false)
*/
private $scoreEquipe2;
/**
* #var \Equipes
*
* #ORM\ManyToOne(targetEntity="Equipes")
* #ORM\JoinColumns({
* #ORM\JoinColumn(name="ID_EQUIPE_EQUIPES", referencedColumnName="ID_EQUIPE")
* })
*/
private $idEquipeEquipes;
/**
* #var \Equipes
*
* #ORM\ManyToOne(targetEntity="Equipes")
* #ORM\JoinColumns({
* #ORM\JoinColumn(name="ID_EQUIPE", referencedColumnName="ID_EQUIPE")
* })
*/
private $idEquipe;
/**
* #var \Journee
*
* #ORM\ManyToOne(targetEntity="Journee")
* #ORM\JoinColumns({
* #ORM\JoinColumn(name="ID_JOURNEE", referencedColumnName="ID_JOURNEE")
* })
*/
private $idJournee;
/**
* #var \Doctrine\Common\Collections\Collection
*
* #ORM\ManyToMany(targetEntity="JoueursEquipe", inversedBy="idMatchs")
* #ORM\JoinTable(name="jouer",
* joinColumns={
* #ORM\JoinColumn(name="ID_MATCHS", referencedColumnName="ID_MATCHS")
* },
* inverseJoinColumns={
* #ORM\JoinColumn(name="ID_JOUEUR_EQUIPE", referencedColumnName="ID_JOUEUR_EQUIPE")
* }
* )
*/
private $idJoueurEquipe;
/**
* Constructor
*/
public function __construct()
{
$this->idJoueurEquipe = new \Doctrine\Common\Collections\ArrayCollection();
}
public function getIdMatchs()
{
return $this->idMatchs;
}
public function setIdMatchs(int $idMatchs)
{
$this->idMatchs = $idMatchs;
return $this;
}
/**
* Get the value of dateMatchs
*
* #return \DateTime
*/
public function getDateMatchs()
{
return $this->dateMatchs;
}
/**
* Set the value of dateMatchs
*
* #param \DateTime $dateMatchs
*
* #return self
*/
public function setDateMatchs(\DateTime $dateMatchs)
{
$this->dateMatchs = $dateMatchs;
return $this;
}
/**
* Get the value of resumeMatchs
*
* #return string|null
*/
public function getResumeMatchs()
{
return $this->resumeMatchs;
}
/**
* Set the value of resumeMatchs
*
* #param string|null $resumeMatchs
*
* #return self
*/
public function setResumeMatchs($resumeMatchs)
{
$this->resumeMatchs = $resumeMatchs;
return $this;
}
/**
* Get the value of scoreEquipe1
*
* #return int
*/
public function getScoreEquipe1()
{
return $this->scoreEquipe1;
}
/**
* Set the value of scoreEquipe1
*
* #param int $scoreEquipe1
*
* #return self
*/
public function setScoreEquipe1(int $scoreEquipe1)
{
$this->scoreEquipe1 = $scoreEquipe1;
return $this;
}
/**
* Get the value of scoreEquipe2
*
* #return int
*/
public function getScoreEquipe2()
{
return $this->scoreEquipe2;
}
/**
* Set the value of scoreEquipe2
*
* #param int $scoreEquipe2
*
* #return self
*/
public function setScoreEquipe2(int $scoreEquipe2)
{
$this->scoreEquipe2 = $scoreEquipe2;
return $this;
}
/**
* Get the value of idEquipeEquipes
*
* #return \Equipes
*/
public function getIdEquipeEquipes()
{
return $this->idEquipeEquipes;
}
/**
* Set the value of idEquipeEquipes
*
* #param \Equipes $idEquipeEquipes
*
* #return self
*/
public function setIdEquipeEquipes(\Equipes $idEquipeEquipes)
{
$this->idEquipeEquipes = $idEquipeEquipes;
return $this;
}
/**
* Get the value of idEquipe
*
* #return \Equipes
*/
public function getIdEquipe()
{
return $this->idEquipe;
}
/**
* Set the value of idEquipe
*
* #param \Equipes $idEquipe
*
* #return self
*/
public function setIdEquipe(\Equipes $idEquipe)
{
$this->idEquipe = $idEquipe;
return $this;
}
public function __toString()
{
return $this->nomEquipe;
}
/**
* Get the value of idJournee
*
* #return \Journee
*/
public function getIdJournee()
{
return $this->idJournee;
}
/**
* Set the value of idJournee
*
* #param \Journee $idJournee
*
* #return self
*/
public function setIdJournee(\Journee $idJournee)
{
$this->idJournee = $idJournee;
return $this;
}
public function getTitreMatch(): ?string
{
return $this->titreMatch;
}
public function setTitreMatch(string $titreMatch): self
{
$this->titreMatch = $titreMatch;
return $this;
}
/**
* Get the value of idJoueurEquipe
*
* #return \Doctrine\Common\Collections\Collection
*/
public function getIdJoueurEquipe()
{
return $this->idJoueurEquipe;
}
/**
* Set the value of idJoueurEquipe
*
* #param \Doctrine\Common\Collections\Collection $idJoueurEquipe
*
* #return self
*/
public function setIdJoueurEquipe(\Doctrine\Common\Collections\Collection $idJoueurEquipe)
{
$this->idJoueurEquipe = $idJoueurEquipe;
return $this;
}
public function addIdJoueurEquipe(JoueursEquipe $idJoueurEquipe): self
{
if (!$this->idJoueurEquipe->contains($idJoueurEquipe)) {
$this->idJoueurEquipe[] = $idJoueurEquipe;
}
return $this;
}
public function removeIdJoueurEquipe(JoueursEquipe $idJoueurEquipe): self
{
if ($this->idJoueurEquipe->contains($idJoueurEquipe)) {
$this->idJoueurEquipe->removeElement($idJoueurEquipe);
}
return $this;
}
}
I'm using Sylius 1.0.0-dev and created model called Trainee
<?php
namespace AppBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use SyliusExtensionBundle\Entity\Product;
use SyliusExtensionBundle\Entity\Order;
use Sylius\Component\Resource\Model\ResourceInterface;
/**
* Trainee
*
* #ORM\Table(name="smartbyte_trainee")
* #ORM\Entity()
*/
class Trainee implements ResourceInterface
{
/**
* #var integer
*
* #ORM\Column(name="id", type="integer")
* #ORM\Id
* #ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* #var string
*
* #ORM\Column(name="firstName", type="string", length=255)
*/
private $firstName;
/**
* #var string
*
* #ORM\Column(name="secondName", type="string", length=255)
*/
private $secondName;
/**
* #var string
*
* #ORM\Column(name="email", type="string", length=255)
*/
private $email;
/**
* #var string
*
* #ORM\Column(name="phone", type="string", length=255)
*/
private $phone;
/**
* #var boolean
*
* #ORM\Column(name="is_resignated", type="boolean")
*/
private $isResignated = false;
/**
* #var boolean
*
* #ORM\Column(name="is_present", type="boolean")
*/
private $isPresent = false;
/**
* #var Product
*
* #ORM\ManyToOne(targetEntity="SyliusExtensionBundle\Entity\Product")
* #ORM\JoinColumn(name="product_id", referencedColumnName="id", onDelete="CASCADE")
*/
private $product;
/**
* #var Order
*
* #ORM\ManyToOne(targetEntity="SyliusExtensionBundle\Entity\Order", inversedBy="trainees")
* #ORM\JoinColumn(name="order_id", referencedColumnName="id", onDelete="CASCADE")
*/
private $order;
public function __toString() {
return $this->firstName.' '.$this->secondName;
}
/**
* Get id
*
* #return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set firstName
*
* #param string $firstName
* #return Trainee
*/
public function setFirstName($firstName)
{
$this->firstName = $firstName;
return $this;
}
/**
* Get firstName
*
* #return string
*/
public function getFirstName()
{
return $this->firstName;
}
/**
* Set secondName
*
* #param string $secondName
* #return Trainee
*/
public function setSecondName($secondName)
{
$this->secondName = $secondName;
return $this;
}
/**
* Get secondName
*
* #return string
*/
public function getSecondName()
{
return $this->secondName;
}
/**
* Set email
*
* #param string $email
* #return Trainee
*/
public function setEmail($email)
{
$this->email = $email;
return $this;
}
/**
* Get email
*
* #return string
*/
public function getEmail()
{
return $this->email;
}
/**
* Set phone
*
* #param string $phone
* #return Trainee
*/
public function setPhone($phone)
{
$this->phone = $phone;
return $this;
}
/**
* Get phone
*
* #return string
*/
public function getPhone()
{
return $this->phone;
}
/**
* #var string
*/
private $condition;
/**
* Set isResignated
*
* #param boolean $isResignated
* #return Trainee
*/
public function setIsResignated($isResignated)
{
$this->isResignated = $isResignated;
return $this;
}
/**
* Get isResignated
*
* #return boolean
*/
public function getIsResignated()
{
return $this->isResignated;
}
/**
* Set condition
*
* #param string $condition
* #return Trainee
*/
public function setCondition($condition)
{
$this->condition = $condition;
return $this;
}
/**
* Get condition
*
* #return string
*/
public function getCondition()
{
return $this->condition;
}
/**
* Set product
*
* #param Product $product
* #return Trainee
*/
public function setProduct(Product $product = null)
{
$this->product = $product;
return $this;
}
/**
* Get product
*
* #return Product
*/
public function getProduct()
{
return $this->product;
}
/**
* Set order
*
* #param Order $order
* #return Trainee
*/
public function setOrder(Order $order = null)
{
$this->order = $order;
return $this;
}
/**
* Get order
*
* #return Order
*/
public function getOrder()
{
return $this->order;
}
/**
* Set isPresent
*
* #param boolean $isPresent
* #return Trainee
*/
public function setIsPresent($isPresent)
{
$this->isPresent = $isPresent;
return $this;
}
/**
* Get isPresent
*
* #return boolean
*/
public function getIsPresent()
{
return $this->isPresent;
}
}
Then I configure it with config.yml:
sylius_resource:
resources:
app.trainee:
classes:
model: AppBundle\Entity\Trainee
repository: AppBundle\Repository\TraineeRepository
and routing.yml:
app_trainee:
resource: |
alias: app.trainee
section: admin
type: sylius.resource
prefix: /admin
according to the docs. Unfortunately instead of crud template I get :
Unable to find template "/index.html.twig" (looked into: /home/krzysztof/Dokumenty/praca/smartbyte/eventmanager2/vendor/symfony/symfony/src/Symfony/Bridge/Twig/Resources/views/Form, /home/krzysztof/Dokumenty/praca/smartbyte/eventmanager2/vendor/knplabs/knp-menu/src/Knp/Menu/Resources/views).
I know there is SyliusAdminBundle with crud templates for resources but by the last version I was using (0.18) sylius evolved much it's completely different from that.
You should compare your routing.yml code to other resources in the AdminBundle routing files.
This is the product declaration in the routing/product.yml file
sylius_admin_product:
resource: |
alias: sylius.product
section: admin
templates: SyliusAdminBundle:Crud
except: ['show']
redirect: update
grid: sylius_admin_product
permission: true
vars:
all:
subheader: sylius.ui.manage_your_product_catalog
templates:
form: SyliusAdminBundle:Product:_form.html.twig
index:
icon: cube
type: sylius.resource
You should probably put the templates: declaration in
I'm in a deadend and can't seem to find my way out of this apparently simple problem.
I'm working with Symfony2 and trying to create a database table from an Entity that I generated with the generate:doctrine:entity command. But when I run doctrine:schema:create I always get a "No Metadata Classes to process" message like Doctrine can't find my entity.
I checked the database, the namespace, the annotations, tried creating other entities manually instead of by using the generate:doctrine:entity command but I always get the same result.
Here is my entity :
namespace Blogger\BlogBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* #ORM\Entity
* #ORM\Table(name="blog")
*/
class Blog
{
/**
* #var integer
*
* #ORM\Column(name="id", type="integer")
* #ORM\Id
* #ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* #var string
*
* #ORM\Column(name="title", type="string", length=255)
*/
private $title;
/**
* #var string
*
* #ORM\Column(name="author", type="string", length=100)
*/
private $author;
/**
* #var string
*
* #ORM\Column(name="blog", type="text")
*/
private $blog;
/**
* #var string
*
* #ORM\Column(name="image", type="string", length=20)
*/
private $image;
/**
* #var string
*
* #ORM\Column(name="tags", type="text")
*/
private $tags;
/**
* #var \DateTime
*
* #ORM\Column(name="created", type="datetime")
*/
private $created;
/**
* #var \DateTime
*
* #ORM\Column(name="updated", type="datetime")
*/
private $updated;
/**
* Get id
*
* #return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set title
*
* #param string $title
*
* #return Blog
*/
public function setTitle($title)
{
$this->title = $title;
return $this;
}
/**
* Get title
*
* #return string
*/
public function getTitle()
{
return $this->title;
}
/**
* Set author
*
* #param string $author
*
* #return Blog
*/
public function setAuthor($author)
{
$this->author = $author;
return $this;
}
/**
* Get author
*
* #return string
*/
public function getAuthor()
{
return $this->author;
}
/**
* Set blog
*
* #param string $blog
*
* #return Blog
*/
public function setBlog($blog)
{
$this->blog = $blog;
return $this;
}
/**
* Get blog
*
* #return string
*/
public function getBlog()
{
return $this->blog;
}
/**
* Set image
*
* #param string $image
*
* #return Blog
*/
public function setImage($image)
{
$this->image = $image;
return $this;
}
/**
* Get image
*
* #return string
*/
public function getImage()
{
return $this->image;
}
/**
* Set tags
*
* #param string $tags
*
* #return Blog
*/
public function setTags($tags)
{
$this->tags = $tags;
return $this;
}
/**
* Get tags
*
* #return string
*/
public function getTags()
{
return $this->tags;
}
/**
* Set created
*
* #param \DateTime $created
*
* #return Blog
*/
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 Blog
*/
public function setUpdated($updated)
{
$this->updated = $updated;
return $this;
}
/**
* Get updated
*
* #return \DateTime
*/
public function getUpdated()
{
return $this->updated;
}
}
I'm getting out of ideas. I saw other similar questions but none that could help me. If someone knows what to do, I'd love your help ;)
Something weird happened to me when I put my entity class in a directory called Models, so my namespace was:
AppBundle\Models
But it didn't work.
So I removed that folder and create another folder exactly named Entity and it worked.
So try to remove BlogBundle and put your Entity folder right under you Appbundle folder
Most of the time This error come because of entity path issue and cache
run command first
doctrine:cache:clear-metadata
and then try
doctrine:schema:create
I had the same problem. Try to remove Blogger from your namespace:
namespace BlogBundle\Entity;
I have a weird problem when I want to generate my database schema on Symfony2, one attribut is not accepted...
The annotation "#Doctrine\ORM\Mapping\ManyToOne" in property L3L2\EntraideBundle\Entity\RendezVous::$idDispoProf does not exist, or could not be auto-loaded.
It's even weirder because its working on MacOS X and Windows (Vista & Seven). I tried to make it works on Ubuntu Server VM.
Here is my entities code :
<?php
namespace L3L2\EntraideBundle\Entity;
use L3L2\UserBundle\Entity\User;
use Doctrine\ORM\Mapping as ORM;
/**
* RendezVous
*
* #ORM\Table()
* #ORM\Entity(repositoryClass="L3L2\EntraideBundle\Entity\RendezVousRepository")
*/
class RendezVous
{
/**
* Constructor
*/
public function __construct()
{
$this->vuEleve = "NON";
$this->vuProf = "NON";
}
/**
* #var integer
*
* #ORM\Column(name="id", type="integer")
* #ORM\Id
* #ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* #var string
*
* #ORM\Column(name="lieu", type="string", length=255)
*/
private $lieu;
/**
* #var string
*
* #ORM\Column(name="statut", type="string", length=255)
*/
private $statut;
/**
* #var \DateTime
*
* #ORM\Column(name="date", type="date")
*/
private $date;
/**
* #var \DateTime
*
* #ORM\Column(name="time", type="time")
*/
private $time;
/**
* #var \DateTime
*
* #ORM\Column(name="datetimeDebut", type="datetime")
*/
private $datetimeDebut;
/**
* #var \DateTime
*
* #ORM\Column(name="datetimeFin", type="datetime")
*/
private $datetimeFin;
//Création de OneToOne vers Evaluation
/**
* #ORM\OneToOne(targetEntity="L3L2\EntraideBundle\Entity\Evaluation", mappedBy="idRdvEval")
* #ORM\JoinColumn(name="id_eval", referencedColumnName="id")
*/
protected $evaluationRdv;
//PROBLEM HERE !!
// Création de ManytoOne vers Disponibilite
/**
* #ORM\ManytoOne(targetEntity="L3L2\EntraideBundle\Entity\Disponibilite")
* #ORM\JoinColumn(name="id_dispo_prof", referencedColumnName="id", onDelete="SET NULL")
*/
protected $idDispoProf;
//Création de ManyToOne vers Cours
/**
* #ORM\ManyToOne(targetEntity="L3L2\EntraideBundle\Entity\Cours", inversedBy="rendezVousCours")
* #ORM\JoinColumn(name="id_cours_rdv", referencedColumnName="id")
*/
protected $idCoursRdv;
//Création de ManyToOne vers User
/**
* #ORM\ManyToOne(targetEntity="L3L2\UserBundle\Entity\User", inversedBy="rendezVousEleve")
* #ORM\JoinColumn(name="id_eleve_rdv", referencedColumnName="id")
*/
protected $idEleveRdv;
/**
* #var string
*
* #ORM\Column(name="vuEleve", type="string", length=255, nullable=true)
*/
private $vuEleve;
/**
* #var string
*
* #ORM\Column(name="vuProf", type="string", length=255, nullable=true)
*/
private $vuProf;
//Création de ManyToOne vers User
/**
* #ORM\ManyToOne(targetEntity="L3L2\UserBundle\Entity\User")
* #ORM\JoinColumn(name="dernierModif", referencedColumnName="id")
*/
private $dernierModif;
/**
* Get id
*
* #return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set lieu
*
* #param string $lieu
* #return RendezVous
*/
public function setLieu($lieu)
{
$this->lieu = $lieu;
return $this;
}
/**
* Get lieu
*
* #return string
*/
public function getLieu()
{
return $this->lieu;
}
/**
* Set statut
*
* #param string $statut
* #return RendezVous
*/
public function setStatut($statut)
{
$this->statut = $statut;
return $this;
}
/**
* Get statut
*
* #return string
*/
public function getStatut()
{
return $this->statut;
}
/**
* Set evaluationRdv
*
* #param \L3L2\EntraideBundle\Entity\Evaluation $evaluationRdv
* #return RendezVous
*/
public function setEvaluationRdv(\L3L2\EntraideBundle\Entity\Evaluation $evaluationRdv = null)
{
$this->evaluationRdv = $evaluationRdv;
return $this;
}
/**
* Get evaluationRdv
*
* #return \L3L2\EntraideBundle\Entity\Evaluation
*/
public function getEvaluationRdv()
{
return $this->evaluationRdv;
}
/**
* Set idEleveRdv
*
* #param \L3L2\UserBundle\Entity\User $idEleveRdv
* #return RendezVous
*/
public function setIdEleveRdv(\L3L2\UserBundle\Entity\User $idEleveRdv = null)
{
return $this->idEleveRdv = $idEleveRdv;
}
/**
* Get idEleveRdv
*
* #return \L3L2\UserBundle\Entity\User
*/
public function getIdEleveRdv()
{
return $this->idEleveRdv;
}
/**
* Set idDispoProf
*
* #param \L3L2\EntraideBundle\Entity\Disponibilite $idDispoProf
* #return RendezVous
*/
public function setIdDispoProf(\L3L2\EntraideBundle\Entity\Disponibilite $idDispoProf = null)
{
return $this->idDispoProf = $idDispoProf;
}
/**
* Get idDispoProf
*
* #return \L3L2\EntraideBundle\Entity\Disponibilite
*/
public function getIdDispoProf()
{
return $this->idDispoProf;
}
/**
* Set idCoursRdv
*
* #param \L3L2\EntraideBundle\Entity\Cours $idCoursRdv
* #return RendezVous
*/
public function setIdCoursRdv(\L3L2\EntraideBundle\Entity\Cours $idCoursRdv = null)
{
return $this->idCoursRdv = $idCoursRdv;
}
/**
* Get idCoursRdv
*
* #return \L3L2\EntraideBundle\Entity\Cours
*/
public function getIdCoursRdv()
{
return $this->idCoursRdv;
}
/**
* Set date
*
* #param \DateTime $date
* #return RendezVous
*/
public function setDate($date)
{
$this->date = clone $date;
return $this;
}
/**
* Get date
*
* #return \DateTime
*/
public function getDate()
{
return clone $this->date;
}
/**
* Set time
*
* #param \DateTime $time
* #return RendezVous
*/
public function setTime($time)
{
$this->time = clone $time;
return $this;
}
/**
* Get time
*
* #return \DateTime
*/
public function getTime()
{
return clone $this->time;
}
/**
* Set vuEleve
*
* #param string $vuEleve
* #return RendezVous
*/
public function setVuEleve($vuEleve)
{
$this->vuEleve = $vuEleve;
return $this;
}
/**
* Get vuEleve
*
* #return string
*/
public function getVuEleve()
{
return $this->vuEleve;
}
/**
* Set vuProf
*
* #param string $vuProf
* #return RendezVous
*/
public function setVuProf($vuProf)
{
$this->vuProf = $vuProf;
return $this;
}
/**
* Get vuProf
*
* #return string
*/
public function getVuProf()
{
return $this->vuProf;
}
/**
* Set datetimeDebut
*
* #param \DateTime $datetimeDebut
* #return RendezVous
*/
public function setDatetimeDebut($datetimeDebut)
{
$this->datetimeDebut = $datetimeDebut;
return $this;
}
/**
* Get datetimeDebut
*
* #return \DateTime
*/
public function getDatetimeDebut()
{
return $this->datetimeDebut;
}
/**
* Set datetimeFin
*
* #param \DateTime $datetimeFin
* #return RendezVous
*/
public function setDatetimeFin($datetimeFin)
{
$this->datetimeFin = $datetimeFin;
return $this;
}
/**
* Get datetimeFin
*
* #return \DateTime
*/
public function getDatetimeFin()
{
return $this->datetimeFin;
}
/**
* Set dernierModif
*
* #param \L3L2\UserBundle\Entity\User $dernierModif
* #return RendezVous
*/
public function setDernierModif(\L3L2\UserBundle\Entity\User $dernierModif = null)
{
$this->dernierModif = $dernierModif;
return $this;
}
/**
* Get dernierModif
*
* #return \L3L2\UserBundle\Entity\User
*/
public function getDernierModif()
{
return $this->dernierModif;
}
}
If I remove the $idDispoProf or annotations before $idDispoProf I can schema:update...
Any idea ?
You have ManytoOne written in lowercase in this specific property instead of ManyToOne in rest of them. Autoloader works in Windows probably because for this system file called ManyToOne.php and ManytoOne.php is the same - Linux is case sensitive.
So solution for you: change ManytoOne to ManyToOne
I am trying to set some translatable contents in Symfony2 with Gedmo Translatable but seems I am doing something wrong or missing something.
I included the line in the composer.json file:
"gedmo/doctrine-extensions": "2.3.*#dev"
And also, I added this lines in the config.yml file:
stof_doctrine_extensions:
orm:
alopatria:
timestampable: true
sluggable: true
translatable: true
The entity class is set like this:
<?php
namespace ...;
use Gedmo\Mapping\Annotation as Gedmo;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Translatable\Translatable;
/**
* ...\Entity
*
* #ORM\Table(name="content")
* #ORM\HasLifecycleCallbacks
* #ORM\Entity(repositoryClass="...\Entity\ContentRepository")
*/
class Content implements Translatable
{
/**
*
* #ORM\Column(name="id", type="bigint", nullable=false)
* #ORM\Id
* #ORM\GeneratedValue(strategy="IDENTITY")
*/
protected $id;
/**
* #Gedmo\Translatable
* #ORM\Column(name="title", type="string", length=32, nullable=false)
*/
protected $title;
/**
* #Gedmo\Translatable
* #ORM\Column(name="text", type="text", nullable=false)
*/
protected $text;
/**
* #var datetime $created
*
* #Gedmo\Timestampable(on="create")
* #ORM\Column(type="datetime")
*/
private $created;
/**
* #var datetime $updated
*
* #Gedmo\Timestampable(on="update")
* #ORM\Column(type="datetime")
*/
private $updated;
/**
* #var datetime $contentChanged
*
* #ORM\Column(name="content_changed", type="datetime", nullable=true)
* #Gedmo\Timestampable(on="change", field={"title", "text"})
*/
private $contentChanged;
/**
* #Gedmo\Slug(fields={"title"})
* #ORM\Column(length=128, unique=true)
*/
private $slug;
/**
* Get id
*
* #return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set title
*
* #param string $title
* #return Content
*/
public function setTitle($title)
{
$this->title = $title;
return $this;
}
/**
* Get title
*
* #return string
*/
public function getTitle()
{
return $this->title;
}
/**
* Set text
*
* #param string $text
* #return Content
*/
public function setText($text)
{
$this->text = $text;
return $this;
}
/**
* Get text
*
* #return string
*/
public function getText()
{
return $this->text;
}
/**
* Set created
*
* #param \DateTime $created
* #return Content
*/
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 Content
*/
public function setUpdated($updated)
{
$this->updated = $updated;
return $this;
}
/**
* Get updated
*
* #return \DateTime
*/
public function getUpdated()
{
return $this->updated;
}
/**
* Set contentChanged
*
* #param \DateTime $contentChanged
* #return Content
*/
public function setContentChanged($contentChanged)
{
$this->contentChanged = $contentChanged;
return $this;
}
/**
* Get contentChanged
*
* #return \DateTime
*/
public function getContentChanged()
{
return $this->contentChanged;
}
/**
* Set slug
*
* #param string $slug
* #return Content
*/
public function setSlug($slug)
{
$this->slug = $slug;
return $this;
}
/**
* Get slug
*
* #return string
*/
public function getSlug()
{
return $this->slug;
}
}
When I try to create a translatable content in my controller:
$content = new Content();
$content->setTitle('Content example');
$content->setText('Content example...');
$em = $this->getDoctrine()->getEntityManager();
$em->persist($content);
$em->flush();
$content->setTranslatableLocale('fr'); // change locale
$em->persist($content);
$em->flush();
This is the error:
The class 'Gedmo\Translatable\Entity\Translation' was not found in the chain configured namespaces ...\Entity, FOS\UserBundle\Model
Any help? Thanks!!!
You need to configure the translatable Entity to use as well. In config.yml:
orm:
auto_generate_proxy_classes: %kernel.debug%
mappings:
translatable:
type: annotation
is_bundle: false
prefix: Gedmo\Translatable\Entity
dir: "%kernel.root_dir%/../vendor/gedmo/doctrine-extensions/lib/Gedmo/Translatable/Entity"
alias: GedmoTranslatable