Retrieve user from existing table User - php

I'm really new to Symfony and I'm learning how it works.
So I have a DB and a table on it called USER with the fields name,username,password etc etc.
I'm trying to create a login form that will take the user from that table.
I've already created my enity User
I've read the doc here, but it's not what I want, because as i said my entity it's still there.
Should I use FOS user bunble? I've read the doc here of this bundle, but I didn't get the final part (step7).So my question is, can I use my User Entity with FOS user Bundle? If the answer is no, there is another solution to that, sicne I don't what to change my DB table?
Thank everyone in advance
P.s I generated the User entity following this dochere and this is the resulting class
namespace LocalWorker\BackendBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* Utente
*/
class Utente
{
/**
* #var string
*/
private $uNome;
/**
* #var string
*/
private $uCognome;
/**
* #var string
*/
private $uUsername;
/**
* #var string
*/
private $uPassword;
/**
* #var string
*/
private $uEmail;
/**
* #var string
*/
private $uRuolo;
/**
* #var integer
*/
private $uStatus;
/**
* #var \DateTime
*/
private $uDateIns;
/**
* #var \DateTime
*/
private $uDateActive;
/**
* #var integer
*/
private $uId;
/**
* Set uNome
*
* #param string $uNome
* #return Utente
*/
public function setUNome($uNome)
{
$this->uNome = $uNome;
return $this;
}
/**
* Get uNome
*
* #return string
*/
public function getUNome()
{
return $this->uNome;
}
/**
* Set uCognome
*
* #param string $uCognome
* #return Utente
*/
public function setUCognome($uCognome)
{
$this->uCognome = $uCognome;
return $this;
}
/**
* Get uCognome
*
* #return string
*/
public function getUCognome()
{
return $this->uCognome;
}
/**
* Set uUsername
*
* #param string $uUsername
* #return Utente
*/
public function setUUsername($uUsername)
{
$this->uUsername = $uUsername;
return $this;
}
/**
* Get uUsername
*
* #return string
*/
public function getUUsername()
{
return $this->uUsername;
}
/**
* Set uPassword
*
* #param string $uPassword
* #return Utente
*/
public function setUPassword($uPassword)
{
$this->uPassword = $uPassword;
return $this;
}
/**
* Get uPassword
*
* #return string
*/
public function getUPassword()
{
return $this->uPassword;
}
/**
* Set uEmail
*
* #param string $uEmail
* #return Utente
*/
public function setUEmail($uEmail)
{
$this->uEmail = $uEmail;
return $this;
}
/**
* Get uEmail
*
* #return string
*/
public function getUEmail()
{
return $this->uEmail;
}
/**
* Set uRuolo
*
* #param string $uRuolo
* #return Utente
*/
public function setURuolo($uRuolo)
{
$this->uRuolo = $uRuolo;
return $this;
}
/**
* Get uRuolo
*
* #return string
*/
public function getURuolo()
{
return $this->uRuolo;
}
/**
* Set uStatus
*
* #param integer $uStatus
* #return Utente
*/
public function setUStatus($uStatus)
{
$this->uStatus = $uStatus;
return $this;
}
/**
* Get uStatus
*
* #return integer
*/
public function getUStatus()
{
return $this->uStatus;
}
/**
* Set uDateIns
*
* #param \DateTime $uDateIns
* #return Utente
*/
public function setUDateIns($uDateIns)
{
$this->uDateIns = $uDateIns;
return $this;
}
/**
* Get uDateIns
*
* #return \DateTime
*/
public function getUDateIns()
{
return $this->uDateIns;
}
/**
* Set uDateActive
*
* #param \DateTime $uDateActive
* #return Utente
*/
public function setUDateActive($uDateActive)
{
$this->uDateActive = $uDateActive;
return $this;
}
/**
* Get uDateActive
*
* #return \DateTime
*/
public function getUDateActive()
{
return $this->uDateActive;
}
/**
* Get uId
*
* #return integer
*/
public function getUId()
{
return $this->uId;
}
}

Related

Symfony2.3 Unrecognized field ORMexception

I'm having a similiar issue to Symfony2 Doctrine Unrecognized field:
But mine doesn't have the same solution
I have an entity "category" I'm trying to find all the categories with the attribute "activo" set to true but it gives me the error in the title
I've done php app/console doctrine:generate:entities [path] --no-backup and php app/console doctrine:schema:update --force
My table in my database is updated just as my entity.
<?php
namespace ROSHKA\BBVA\SitioExperience\FrontendBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* Expcategorias
*/
class Expcategorias
{
/**
* #var integer
*/
private $id;
/**
* #var string
*/
private $nombre;
/**
* #var string
*/
private $descripcion;
/**
* #var \ROSHKA\BBVA\SitioUniversos\ImagenesBundle\Entity\Imagenes
*/
private $imagen;
/**
* #var string
*/
private $titulo;
/**
* #var boolean
*/
private $activo;
/**
* #var string
*/
private $colorfondo;
/**
* #var \ROSHKA\BBVA\SitioUniversos\ImagenesBundle\Entity\Imagenes
*/
private $imagenfondo;
/**
* Get id
*
* #return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set nombre
*
* #param string $nombre
* #return Expcategorias
*/
public function setNombre($nombre)
{
$this->nombre = $nombre;
return $this;
}
/**
* Get nombre
*
* #return string
*/
public function getNombre()
{
return $this->nombre;
}
/**
* Set descripcion
*
* #param string $descripcion
* #return Expcategorias
*/
public function setDescripcion($descripcion)
{
$this->descripcion = $descripcion;
return $this;
}
/**
* Get descripcion
*
* #return string
*/
public function getDescripcion()
{
return $this->descripcion;
}
/**
* Set imagen
*
* #param \ROSHKA\BBVA\SitioUniversos\ImagenesBundle\Entity\Imagenes $imagen
* #return Expcategorias
*/
public function setImagen(\ROSHKA\BBVA\SitioUniversos\ImagenesBundle\Entity\Imagenes $imagen = null)
{
$this->imagen = $imagen;
return $this;
}
/**
* Get imagen
*
* #return \ROSHKA\BBVA\SitioUniversos\ImagenesBundle\Entity\Imagenes
*/
public function getImagen()
{
return $this->imagen;
}
public function __toString()
{
return $this->getNombre();
}
/**
* Set titulo
*
* #param string $titulo
* #return Expcategorias
*/
public function setTitulo($titulo)
{
$this->titulo = $titulo;
return $this;
}
/**
* Get titulo
*
* #return string
*/
public function getTitulo()
{
return $this->titulo;
}
/**
* Set activo
*
* #param boolean $activo
* #return Expcategorias
*/
public function setActivo($activo)
{
$this->activo = $activo;
return $this;
}
/**
* Get activo
*
* #return boolean
*/
public function getActivo()
{
return $this->activo;
}
/**
* Set colorfondo
*
* #param string $colorfondo
* #return Expcategorias
*/
public function setColorfondo($colorfondo)
{
$this->colorfondo = $colorfondo;
return $this;
}
/**
* Get colorfondo
*
* #return string
*/
public function getColorfondo()
{
return $this->colorfondo;
}
/**
* Set imagenfondo
*
* #param \ROSHKA\BBVA\SitioUniversos\ImagenesBundle\Entity\Imagenes $imagenfondo
* #return Expcategorias
*/
public function setImagenfondo(\ROSHKA\BBVA\SitioUniversos\ImagenesBundle\Entity\Imagenes $imagenfondo = null)
{
$this->imagenfondo = $imagenfondo;
return $this;
}
/**
* Get imagenfondo
*
* #return \ROSHKA\BBVA\SitioUniversos\ImagenesBundle\Entity\Imagenes
*/
public function getImagenfondo()
{
return $this->imagenfondo;
}
}
This is what I use to call it in my controller. When I debug and set a breakpoint here i can see in the expressions sections that my category only has three columns instead of the 9 columns that should have. I don't know what else to do.
$repo = $this->getDoctrine()->getRepository('ROSHKABBVASitioExperienceFrontendBundle:Expcategorias');
$categorias = $repo->findBy(array('activo'=>true));
After thinking for a while I remembered I've installed memcached, then all I did was restart memcached in the task manager, then my project took all the new values.

Methods not found so i cant get Events from DB

Im using adesigns/calendar-bundle to create a calendar on my symfony project.
I Can't get events from the DB when i access fc-load-events, This is my entity listener :
class CalendarEventListener
{
private $entityManager;
public function __construct(EntityManager $entityManager)
{
$this->entityManager = $entityManager;
}
public function loadEvents(CalendarEvent $calendarEvent)
{
$startDate = $calendarEvent->getStartDatetime();
$endDate = $calendarEvent->getEndDatetime();
// The original request so you can get filters from the calendar
// Use the filter in your query for example
$request = $calendarEvent->getRequest();
$filter = $request->get('filter');
// load events using your custom logic here,
// for instance, retrieving events from a repository
$companyEvents = $this->entityManager->getRepository('CMRBundle:EventEntity')
->createQueryBuilder('company_events')
->where('company_events.event_datetime BETWEEN :startDate and :endDate')
->setParameter('startDate', $startDate->format('Y-m-d H:i:s'))
->setParameter('endDate', $endDate->format('Y-m-d H:i:s'))
->getQuery()->getResult();
// $companyEvents and $companyEvent in this example
// represent entities from your database, NOT instances of EventEntity
// within this bundle.
//
// Create EventEntity instances and populate it's properties with data
// from your own entities/database values.
foreach($companyEvents as $companyEvent) {
// create an event with a start/end time, or an all day event
if ($companyEvent->getAllDayEvent() === false) {
$eventEntity = new EventEntity($companyEvent->getTitle(), $companyEvent->getStartDatetime(), $companyEvent->getEndDatetime());
} else {
$eventEntity = new EventEntity($companyEvent->getTitle(), $companyEvent->getStartDatetime(), null, true);
}
//optional calendar event settings
$eventEntity->setAllDay(true); // default is false, set to true if this is an all day event
$eventEntity->setBgColor('#FF0000'); //set the background color of the event's label
$eventEntity->setFgColor('#FFFFFF'); //set the foreground color of the event's label
$eventEntity->setUrl('http://www.google.com'); // url to send user to when event label is clicked
$eventEntity->setCssClass('my-custom-class'); // a custom class you may want to apply to event labels
//finally, add the event to the CalendarEvent for displaying on the calendar
$calendarEvent->addEvent($eventEntity);
}
}
}
This is the error i get :
if ($companyEvent->getAllDayEvent() === false) {
$eventEntity = new EventEntity($companyEvent->getTitle(), $companyEvent->getStartDatetime(), $companyEvent->getEndDatetime());
} else {
$eventEntity = new EventEntity($companyEvent->getTitle(), $companyEvent->getStartDatetime(), null, true);
}
All the methods in evententity are not found : `getAllDayEvent(), getTitle(), getStartDatetime().
I have a public fonction getDaterdv in my entity :
(Ive changed the entity) to RDV :
<?php
namespace CMRBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* RDV
*
* #ORM\Table(name="r_d_v")
* #ORM\Entity(repositoryClass="CMRBundle\Repository\RDVRepository")
*/
class RDV
{
/**
* #var int
*
* #ORM\Column(name="id", type="integer")
* #ORM\Id
* #ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* #var \DateTime
*
* #ORM\Column(name="datecrea", type="datetime")
*/
private $datecrea;
/**
* #ORM\Column(name="published", type="boolean")
*/
private $published = true;
/**
* #var \DateTime
*
* #ORM\Column(name="daterdv", type="datetime")
*/
private $daterdv;
/**
* #var string
*
* #ORM\Column(name="title", type="string", length=255)
*/
private $title;
/**
* #var string
*
* #ORM\Column(name="agentname", type="string", length=255)
*/
private $agentname;
/**
* #var string
*
* #ORM\Column(name="qualif", type="string", length=255)
*/
private $qualif;
/**
* #var int
*
* #ORM\Column(name="agentid", type="integer")
*/
private $agentid;
/**
* #var string
*
* #ORM\Column(name="company", type="string", length=255)
*/
private $company;
/**
* #var string
*
* #ORM\Column(name="comname", type="string", length=255)
*/
private $comname;
/**
* #var text
*
* #ORM\Column(name="content", type="text")
*/
private $content;
/**
* #var text
*
* #ORM\Column(name="adresse", type="text")
*/
private $adresse;
/**
* #var text
*
* #ORM\Column(name="ville", type="text")
*/
private $ville;
/**
* #var text
*
* #ORM\Column(name="telfixe", type="text")
*/
private $telfixe;
/**
* #var text
*
* #ORM\Column(name="telpor", type="text")
*/
private $telpor;
/**
* #var text
*
* #ORM\Column(name="tarif", type="text")
*/
private $tarif;
/**
* #var text
*
* #ORM\Column(name="support", type="text")
*/
private $support;
public function __construct()
{
$this->datecrea = new \Datetime();
$this->daterdv = new \DateTime();
}
/**
* Get id
*
* #return int
*/
public function getId()
{
return $this->id;
}
/**
* Set datecrea
*
* #param \DateTime $datecrea
*
* #return RDV
*/
public function setDatecrea($datecrea)
{
$this->datecrea = $datecrea;
return $this;
}
/**
* Get datecrea
*
* #return \DateTime
*/
public function getDatecrea()
{
return $this->datecrea;
}
/**
* Set daterdv
*
* #param \DateTime $daterdv
*
* #return RDV
*/
public function setDaterdv($daterdv)
{
$this->daterdv = $daterdv;
return $this;
}
/**
* Get daterdv
*
* #return \DateTime
*/
public function getDaterdv()
{
return $this->daterdv;
}
/**
* Set title
*
* #param string $title
*
* #return RDV
*/
public function setTitle($title)
{
$this->title = $title;
return $this;
}
/**
* Get title
*
* #return string
*/
public function getTitle()
{
return $this->title;
}
/**
* Set agentid
*
* #param integer $agentid
*
* #return RDV
*/
public function setAgentid($agentid)
{
$this->agentid = $agentid;
return $this;
}
/**
* Get agentid
*
* #return int
*/
public function getAgentid()
{
return $this->agentid;
}
/**
* Set company
*
* #param string $company
*
* #return RDV
*/
public function setCompany($company)
{
$this->company = $company;
return $this;
}
/**
* Get company
*
* #return string
*/
public function getCompany()
{
return $this->company;
}
/**
* Set content
*
* #param string $content
*
* #return RDV
*/
public function setContent($content)
{
$this->content = $content;
return $this;
}
/**
* Get content
*
* #return string
*/
public function getContent()
{
return $this->content;
}
/**
* Set published
*
* #param boolean $published
*
* #return RDV
*/
public function setPublished($published)
{
$this->published = $published;
return $this;
}
/**
* Get published
*
* #return boolean
*/
public function getPublished()
{
return $this->published;
}
/**
* Set agentname
*
* #param string $agentname
*
* #return RDV
*/
public function setAgentname($agentname)
{
$this->agentname = $agentname;
return $this;
}
/**
* Get agentname
*
* #return string
*/
public function getAgentname()
{
return $this->agentname;
}
/**
* Set adresse
*
* #param string $adresse
*
* #return RDV
*/
public function setAdresse($adresse)
{
$this->adresse = $adresse;
return $this;
}
/**
* Get adresse
*
* #return string
*/
public function getAdresse()
{
return $this->adresse;
}
/**
* Set ville
*
* #param string $ville
*
* #return RDV
*/
public function setVille($ville)
{
$this->ville = $ville;
return $this;
}
/**
* Get ville
*
* #return string
*/
public function getVille()
{
return $this->ville;
}
/**
* Set telfixe
*
* #param string $telfixe
*
* #return RDV
*/
public function setTelfixe($telfixe)
{
$this->telfixe = $telfixe;
return $this;
}
/**
* Get telfixe
*
* #return string
*/
public function getTelfixe()
{
return $this->telfixe;
}
/**
* Set telpor
*
* #param string $telpor
*
* #return RDV
*/
public function setTelpor($telpor)
{
$this->telpor = $telpor;
return $this;
}
/**
* Get telpor
*
* #return string
*/
public function getTelpor()
{
return $this->telpor;
}
/**
* Set tarif
*
* #param string $tarif
*
* #return RDV
*/
public function setTarif($tarif)
{
$this->tarif = $tarif;
return $this;
}
/**
* Get tarif
*
* #return string
*/
public function getTarif()
{
return $this->tarif;
}
/**
* Set support
*
* #param string $support
*
* #return RDV
*/
public function setSupport($support)
{
$this->support = $support;
return $this;
}
/**
* Get support
*
* #return string
*/
public function getSupport()
{
return $this->support;
}
/**
* Set horaire
*
* #param string $horaire
*
* #return RDV
*/
public function setHoraire($horaire)
{
$this->horaire = $horaire;
return $this;
}
/**
* Get horaire
*
* #return string
*/
public function getHoraire()
{
return $this->horaire;
}
/**
* Set comname
*
* #param string $comname
*
* #return RDV
*/
public function setComname($comname)
{
$this->comname = $comname;
return $this;
}
/**
* Get comname
*
* #return string
*/
public function getComname()
{
return $this->comname;
}
/**
* Set qualif
*
* #param string $qualif
*
* #return RDV
*/
public function setQualif($qualif)
{
$this->qualif = $qualif;
return $this;
}
/**
* Get qualif
*
* #return string
*/
public function getQualif()
{
return $this->qualif;
}
}
Thanks for helping me
I have a public fonction getDaterdv in my entity :
(Ive changed the entity) to RDV :
<?php
namespace CMRBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* RDV
*
* #ORM\Table(name="r_d_v")
* #ORM\Entity(repositoryClass="CMRBundle\Repository\RDVRepository")
*/
class RDV
{
/**
* #var int
*
* #ORM\Column(name="id", type="integer")
* #ORM\Id
* #ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* #var \DateTime
*
* #ORM\Column(name="datecrea", type="datetime")
*/
private $datecrea;
/**
* #ORM\Column(name="published", type="boolean")
*/
private $published = true;
/**
* #var \DateTime
*
* #ORM\Column(name="daterdv", type="datetime")
*/
private $daterdv;
/**
* #var string
*
* #ORM\Column(name="title", type="string", length=255)
*/
private $title;
/**
* #var string
*
* #ORM\Column(name="agentname", type="string", length=255)
*/
private $agentname;
/**
* #var string
*
* #ORM\Column(name="qualif", type="string", length=255)
*/
private $qualif;
/**
* #var int
*
* #ORM\Column(name="agentid", type="integer")
*/
private $agentid;
/**
* #var string
*
* #ORM\Column(name="company", type="string", length=255)
*/
private $company;
/**
* #var string
*
* #ORM\Column(name="comname", type="string", length=255)
*/
private $comname;
/**
* #var text
*
* #ORM\Column(name="content", type="text")
*/
private $content;
/**
* #var text
*
* #ORM\Column(name="adresse", type="text")
*/
private $adresse;
/**
* #var text
*
* #ORM\Column(name="ville", type="text")
*/
private $ville;
/**
* #var text
*
* #ORM\Column(name="telfixe", type="text")
*/
private $telfixe;
/**
* #var text
*
* #ORM\Column(name="telpor", type="text")
*/
private $telpor;
/**
* #var text
*
* #ORM\Column(name="tarif", type="text")
*/
private $tarif;
/**
* #var text
*
* #ORM\Column(name="support", type="text")
*/
private $support;
public function __construct()
{
$this->datecrea = new \Datetime();
$this->daterdv = new \DateTime();
}
/**
* Get id
*
* #return int
*/
public function getId()
{
return $this->id;
}
/**
* Set datecrea
*
* #param \DateTime $datecrea
*
* #return RDV
*/
public function setDatecrea($datecrea)
{
$this->datecrea = $datecrea;
return $this;
}
/**
* Get datecrea
*
* #return \DateTime
*/
public function getDatecrea()
{
return $this->datecrea;
}
/**
* Set daterdv
*
* #param \DateTime $daterdv
*
* #return RDV
*/
public function setDaterdv($daterdv)
{
$this->daterdv = $daterdv;
return $this;
}
/**
* Get daterdv
*
* #return \DateTime
*/
public function getDaterdv()
{
return $this->daterdv;
}
/**
* Set title
*
* #param string $title
*
* #return RDV
*/
public function setTitle($title)
{
$this->title = $title;
return $this;
}
/**
* Get title
*
* #return string
*/
public function getTitle()
{
return $this->title;
}
/**
* Set agentid
*
* #param integer $agentid
*
* #return RDV
*/
public function setAgentid($agentid)
{
$this->agentid = $agentid;
return $this;
}
/**
* Get agentid
*
* #return int
*/
public function getAgentid()
{
return $this->agentid;
}
/**
* Set company
*
* #param string $company
*
* #return RDV
*/
public function setCompany($company)
{
$this->company = $company;
return $this;
}
/**
* Get company
*
* #return string
*/
public function getCompany()
{
return $this->company;
}
/**
* Set content
*
* #param string $content
*
* #return RDV
*/
public function setContent($content)
{
$this->content = $content;
return $this;
}
/**
* Get content
*
* #return string
*/
public function getContent()
{
return $this->content;
}
/**
* Set published
*
* #param boolean $published
*
* #return RDV
*/
public function setPublished($published)
{
$this->published = $published;
return $this;
}
/**
* Get published
*
* #return boolean
*/
public function getPublished()
{
return $this->published;
}
/**
* Set agentname
*
* #param string $agentname
*
* #return RDV
*/
public function setAgentname($agentname)
{
$this->agentname = $agentname;
return $this;
}
/**
* Get agentname
*
* #return string
*/
public function getAgentname()
{
return $this->agentname;
}
/**
* Set adresse
*
* #param string $adresse
*
* #return RDV
*/
public function setAdresse($adresse)
{
$this->adresse = $adresse;
return $this;
}
/**
* Get adresse
*
* #return string
*/
public function getAdresse()
{
return $this->adresse;
}
/**
* Set ville
*
* #param string $ville
*
* #return RDV
*/
public function setVille($ville)
{
$this->ville = $ville;
return $this;
}
/**
* Get ville
*
* #return string
*/
public function getVille()
{
return $this->ville;
}
/**
* Set telfixe
*
* #param string $telfixe
*
* #return RDV
*/
public function setTelfixe($telfixe)
{
$this->telfixe = $telfixe;
return $this;
}
/**
* Get telfixe
*
* #return string
*/
public function getTelfixe()
{
return $this->telfixe;
}
/**
* Set telpor
*
* #param string $telpor
*
* #return RDV
*/
public function setTelpor($telpor)
{
$this->telpor = $telpor;
return $this;
}
/**
* Get telpor
*
* #return string
*/
public function getTelpor()
{
return $this->telpor;
}
/**
* Set tarif
*
* #param string $tarif
*
* #return RDV
*/
public function setTarif($tarif)
{
$this->tarif = $tarif;
return $this;
}
/**
* Get tarif
*
* #return string
*/
public function getTarif()
{
return $this->tarif;
}
/**
* Set support
*
* #param string $support
*
* #return RDV
*/
public function setSupport($support)
{
$this->support = $support;
return $this;
}
/**
* Get support
*
* #return string
*/
public function getSupport()
{
return $this->support;
}
/**
* Set horaire
*
* #param string $horaire
*
* #return RDV
*/
public function setHoraire($horaire)
{
$this->horaire = $horaire;
return $this;
}
/**
* Get horaire
*
* #return string
*/
public function getHoraire()
{
return $this->horaire;
}
/**
* Set comname
*
* #param string $comname
*
* #return RDV
*/
public function setComname($comname)
{
$this->comname = $comname;
return $this;
}
/**
* Get comname
*
* #return string
*/
public function getComname()
{
return $this->comname;
}
/**
* Set qualif
*
* #param string $qualif
*
* #return RDV
*/
public function setQualif($qualif)
{
$this->qualif = $qualif;
return $this;
}
/**
* Get qualif
*
* #return string
*/
public function getQualif()
{
return $this->qualif;
}
}
It should be name of the entity field, but not the name of the database column specified in line
->where('company_events.event_datetime BETWEEN :startDate and :endDate')
so check, maybe it should be like
->where('company_events.eventDatetime BETWEEN :startDate and :endDate')
assuming that you are using camel case on your EventEntity field names using symfony coding style standards.
=============================
UPDATE
=============================
Now, when you posted your entity it is clear that it is not the one you trying to fetch from the database via repository.
$companyEvents = $this->entityManager->getRepository('CMRBundle:EventEntity')
->createQueryBuilder('company_events')
->where('company_events.event_datetime BETWEEN :startDate and :endDate')
->setParameter('startDate', $startDate->format('Y-m-d H:i:s'))
->setParameter('endDate', $endDate->format('Y-m-d H:i:s'))
->getQuery()->getResult();
Here your entity manager retrieving "EventEntity" instances from repository with name "CMRBundle:EventEntity", but to us you showed "RDV" and "CMRBundle\Repository\RDVRepository" to which it belongs to. As far as I understand from the part of the scope you shown - when some calendar event is raised you want to obtain all "event entities" from database which are in bounds of field values set in those event object that you passes to the listener. But it's unclear whether those RDV object that you have shown represent those "event entities" that you want to get from database. For now it looks like so and code related to "CMRBundle:EventEntity" just looks like some example code that your forgot to change. So, please, try to describe us the task and its context more carefully and tell if my assumption is right or wrong.

Relation Many to Many Bidirectional Symfony 3

I'm using Symfony 3 with Doctrine. I have 2 entities in my application, User and Role. I need to make a bidirectional relationship many to many.
I consulted the doctrine documentation.Here is the code:
class Rol
{
/**
* #var int
*
* #ORM\Column(name="id", type="integer")
* #ORM\Id
* #ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* #var string
*
* #ORM\Column(name="nombre", type="string", length=255, unique=true)
*/
private $nombre;
/**
* #var string
*
* #ORM\Column(name="descripcion", type="string", length=255)
*/
private $descripcion;
/**
* #ORM\ManyToMany(targetEntity="Funcionalidad", inversedBy="rolesUsuario")
* #ORM\JoinTable(name="rol_funcionalidad")
*/
private $funcionalidades;
/**
* #ORM\ManyToMany(targetEntity="Usuario", mappedBy="rolesUsuario")
*/
private $usuarios;
public function getAttributes()
{
return get_class_vars(__CLASS__);
}
/**
* Get id
*
* #return int
*/
public function getId()
{
return $this->id;
}
/**
* Set nombre
*
* #param string $nombre
*
* #return Rol
*/
public function setNombre($nombre)
{
$this->nombre = $nombre;
return $this;
}
/**
* Get nombre
*
* #return string
*/
public function getNombre()
{
return $this->nombre;
}
/**
* Set descripcion
*
* #param string $descripcion
*
* #return Rol
*/
public function setDescripcion($descripcion)
{
$this->descripcion = $descripcion;
return $this;
}
/**
* Get descripcion
*
* #return string
*/
public function getDescripcion()
{
return $this->descripcion;
}
/**
* #return string
*/
public function __toString()
{
return $this->getNombre();
}
/**
* Constructor
*/
public function __construct()
{
$this->funcionalidades = new \Doctrine\Common\Collections\ArrayCollection();
$this->usuarios = new \Doctrine\Common\Collections\ArrayCollection();
}
/**
* Add funcionalidade
*
* #param \CECMED\SeguridadBundle\Entity\Rol $funcionalidade
*
* #return Rol
*/
public function addFuncionalidade(\CECMED\SeguridadBundle\Entity\Rol $funcionalidade)
{
$this->funcionalidades[] = $funcionalidade;
return $this;
}
/**
* Remove funcionalidade
*
* #param \CECMED\SeguridadBundle\Entity\Rol $funcionalidade
*/
public function removeFuncionalidade(\CECMED\SeguridadBundle\Entity\Rol $funcionalidade)
{
$this->funcionalidades->removeElement($funcionalidade);
}
/**
* Get funcionalidades
*
* #return \Doctrine\Common\Collections\Collection
*/
public function getFuncionalidades()
{
return $this->funcionalidades;
}
/**
* Add usuario
*
* #param \CECMED\SeguridadBundle\Entity\Usuario $usuario
*
* #return Rol
*/
public function addUsuario(\CECMED\SeguridadBundle\Entity\Usuario $usuario)
{
$usuario->addRolesUsuario($this);
$this->usuarios[] = $usuario;
return $this;
}
/**
* Remove usuario
*
* #param \CECMED\SeguridadBundle\Entity\Usuario $usuario
*/
public function removeUsuario(\CECMED\SeguridadBundle\Entity\Usuario $usuario)
{
$this->usuarios->removeElement($usuario);
}
/**
* Get usuarios
*
* #return \Doctrine\Common\Collections\Collection
*/
public function getUsuarios()
{
return $this->usuarios;
}
}
This is the Usuario Class
class Usuario implements AdvancedUserInterface
{
/**
* #var int
*
* #ORM\Column(name="id", type="integer")
* #ORM\Id
* #ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* #var string
*
* #ORM\Column(name="username", type="string", length=255, unique=true)
*/
private $username;
/**
* #var string
*
* #ORM\Column(name="password", type="string", length=255)
*/
private $password;
/**
* #var string
*
* #ORM\Column(name="estado", type="boolean")
*/
private $estado;
/**
* #var string
*
* #ORM\Column(name="salt", type="string", length=255)
*/
private $salt;
/**
* #ORM\ManyToMany(targetEntity="Rol", inversedBy="usuarios")
* #ORM\JoinTable(name="usuario_rol")
*/
private $rolesUsuario;
/**
* #ORM\OneToOne(targetEntity="Persona")
* #ORM\JoinColumn(name="persona_id", referencedColumnName="id")
*/
private $persona;
public function getAttributes()
{
return get_class_vars(__CLASS__);
}
/**
* Get id
*
* #return int
*/
public function getId()
{
return $this->id;
}
/**
* Set username
*
* #param string $username
*
* #return Usuario
*/
public function setUsername($username)
{
$this->username = $username;
return $this;
}
/**
* Get username
*
* #return string
*/
public function getUsername()
{
return $this->username;
}
/**
* Set password
*
* #param string $password
*
* #return Usuario
*/
public function setPassword($password)
{
$this->password = $password;
return $this;
}
/**
* Get password
*
* #return string
*/
public function getPassword()
{
return $this->password;
}
/**
* Set estado
*
* #param string $estado
*
* #return Usuario
*/
public function setEstado($estado)
{
$this->estado = $estado;
return $this;
}
/**
* Get estado
*
* #return string
*/
public function getEstado()
{
return $this->estado;
}
/**
* Checks whether the user's account has expired.
*
* Internally, if this method returns false, the authentication system
* will throw an AccountExpiredException and prevent login.
*
* #return bool true if the user's account is non expired, false otherwise
*
* #see AccountExpiredException
*/
public function isAccountNonExpired()
{
return true;
}
/**
* Checks whether the user is locked.
*
* Internally, if this method returns false, the authentication system
* will throw a LockedException and prevent login.
*
* #return bool true if the user is not locked, false otherwise
*
* #see LockedException
*/
public function isAccountNonLocked()
{
return true;
}
/**
* Checks whether the user's credentials (password) has expired.
*
* Internally, if this method returns false, the authentication system
* will throw a CredentialsExpiredException and prevent login.
*
* #return bool true if the user's credentials are non expired, false otherwise
*
* #see CredentialsExpiredException
*/
public function isCredentialsNonExpired()
{
return true;
}
/**
* Checks whether the user is enabled.
*
* Internally, if this method returns false, the authentication system
* will throw a DisabledException and prevent login.
*
* #return bool true if the user is enabled, false otherwise
*
* #see DisabledException
*/
public function isEnabled()
{
if($this->estado == true){
return true;
}else{
return false;
}
}
/**
* Returns the roles granted to the user.
*
* <code>
* public function getRoles()
* {
* return array('ROLE_USER');
* }
* </code>
*
* Alternatively, the roles might be stored on a ``roles`` property,
* and populated in any number of different ways when the user object
* is created.
*
* #return (Role|string)[] The user roles
*/
public function getRolesUsuario()
{
return $this->rolesUsuario;
}
public function getRoles()
{
$r = array();
foreach ($this->rolesUsuario as $roles){
$r[] = $roles->getNombre();
}
return $r;
}
/**
* Returns the salt that was originally used to encode the password.
*
* This can return null if the password was not encoded using a salt.
*
* #return string|null The salt
*/
public function getSalt()
{
return $this->salt;
}
/**
* Removes sensitive data from the user.
*
* This is important if, at any given point, sensitive information like
* the plain-text password is stored on this object.
*/
public function eraseCredentials()
{
return false;
}
/**
* Constructor
*/
public function __construct()
{
$this->rolesUsuario = new \Doctrine\Common\Collections\ArrayCollection();
}
/**
* Set salt
*
* #param string $salt
*
* #return Usuario
*/
public function setSalt($salt)
{
$this->salt = $salt;
return $this;
}
/**
* Add role
*
* #param \CECMED\SeguridadBundle\Entity\Rol $role
*
* #return Usuario
*/
public function addRole(\CECMED\SeguridadBundle\Entity\Rol $role)
{
$this->rolesUsuario[] = $role;
return $this;
}
/**
* Remove role
*
* #param \CECMED\SeguridadBundle\Entity\Rol $role
*/
public function removeRole(\CECMED\SeguridadBundle\Entity\Rol $role)
{
$this->rolesUsuario->removeElement($role);
}
/**
* Set persona
*
* #param \CECMED\SeguridadBundle\Entity\persona $persona
*
* #return Usuario
*/
public function setPersona(\CECMED\SeguridadBundle\Entity\persona $persona = null)
{
$this->persona = $persona;
return $this;
}
/**
* Get persona
*
* #return \CECMED\SeguridadBundle\Entity\persona
*/
public function getPersona()
{
return $this->persona;
}
/**
* #return string
*/
public function __toString()
{
return $this->getUsername();
}
/**
* Add rolesUsuario
*
* #param \CECMED\SeguridadBundle\Entity\Rol $rolesUsuario
*
* #return Usuario
*/
public function addRolesUsuario(\CECMED\SeguridadBundle\Entity\Rol $rolesUsuario)
{
$this->rolesUsuario[] = $rolesUsuario;
return $this;
}
/**
* Remove rolesUsuario
*
* #param \CECMED\SeguridadBundle\Entity\Rol $rolesUsuario
*/
public function removeRolesUsuario(\CECMED\SeguridadBundle\Entity\Rol $rolesUsuario)
{
$this->rolesUsuario->removeElement($rolesUsuario);
}
}
The Problem is that, when i generate schema with cli and the CRUD,The Usuario form works fine and it registers the role in database, but the Rol form when I insert a record does not register the user in database
What I have found with my foreign keys in Symfony is #ORM\JoinColumn was redundant. Doctrine can find the column from the #ORM\ManyToMany on its own. It's not clear in the docs in my opinion. I have not tried this with Many to Many relationships, but I have done quite a few Many to Ones. I had several issues until I just deleted all the JoinColumns. Try it out. Let me know how it goes.

Doctrine Get the result of a DQL Query in a nested form

I have the following problem:
I have the following method that fetches the GPS points of a vessel:
/**
* #param array $mmsids
* #param unknown $longituteMin
* #param unknown $longtitudeMax
* #param unknown $latitudeMin
* #param unknown $latitudeMax
* #param \Datetime $timeInterval
*
* #throws EmptyParamGivenException
* #throws Exception
*
* #return Vesel[] with their routes
*/
public function getRoutes(array $mmsids=[],
$longituteMin=null,
$longtitudeMax=null,
$latitudeMin=null,
$latitudeMax=null,
\DateTime $fromDate=null,
\DateTime $toDate=null
) {
$em=$this->getEntityManager();
$query=$em->createQueryBuilder('v')
->from('AppBundle:Vesel', 'v')
->innerJoin('v.veselMoveStatuses','m')
->select('v.mmsi,m.logtitude,m.latitude,m.timestamp')
->addOrderBy('v.mmsi','ASC')
->addOrderBy('m.timestamp','DESC');
if(!empty($longituteMin)){
$query->andWhere('m.logtitude >= :long_min')->setParameter(':long_min',$longituteMin);
}
if(!empty($longtitudeMax)) {
$query->andWhere('m.logtitude <= :long_max')->setParameter(':long_max',$longituteMax);
}
if(!empty($latitudeMin)){
$query->andWhere('m.latitude >= :lat_min')->setParameter(':lat_min',$latitudeMin);
}
if(!empty($latitudeMax)){
$query->andWhere('m.latitude <= :lat_max')->setParameter(':lat_max',$latitudeMin);
}
if(!empty($mmsids)){
$query->andWhere('v.mmsi IN (:mmsids)')->setParameter('mmsids', $mmsids,\Doctrine\DBAL\Connection::PARAM_STR_ARRAY);
}
$paramsToValidate=[RouteInputParameter::PARAM_DATE_FROM=>$fromDate,RouteInputParameter::PARAM_DATE_TO=>$toDate];
if($fromDate!==null && $toDate!==null){
InputValidator::dateRangeValidation($paramsToValidate,RouteInputParameter::PARAM_DATE_FROM,RouteInputParameter::PARAM_DATE_TO);
$query->andWhere('m.timestamp BETWEEN :date_min AND :date_max')
->setParameters(['date_min'=>$fromDate,'date_max'=>$toDate]);
} else if($fromDate!==null) {
$query->andWhere('m.timestamp <= :date_min')
->setParameters(['date_min'=>$fromDate]);
} else if($toDate!==null) {
$query->where('m.timestamp >= :date_max')
->setParameters(['date_max'=>$toDate]);
}
$query = $query->getQuery();
return $query->getResult();
}
What I want to achieve it that I want to generate the result in a nested way like that:
[
[
"mmsi"=>"^somevalue^"
points=>[
"longtitude":"^longtitude_value^",
"latitude":"^latitude_value^",
"time":"^time_value^"
],
....
],
....
]
do you have any idea if there is an internal Doctrine mechanism that allows me to do this or should I implement my own?
The Vessel Entity is:
namespace AppBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* #ORM\Entity
* #ORM\Table(name="vessel",indexes={
* #ORM\Index(name="mmsi",columns={"mmsi"})
* })
*/
class Vesel
{
/**
* #ORM\Column(type="integer")
* #ORM\Id
* #ORM\GeneratedValue(strategy="AUTO")
* #var integer
*/
private $id;
/**
* #ORM\Column(type="integer",name="mmsi")
* #var integer
*/
private $mmsi;
/**
* #ORM\OneToMany(targetEntity="VesselMoveStatus",mappedBy="vesel")
* #var \Doctrine\Common\Collections\Collection
*/
private $veselMoveStatuses;
/**
* Constructor
*/
public function __construct($mmsi)
{
$this->veselMoveStatuses = new \Doctrine\Common\Collections\ArrayCollection();
$this->setMmsi($mmsi);
}
/**
* Get id
*
* #return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set mmsi
*
* #param integer $mmsi
*
* #return Vesel
*/
public function setMmsi($mmsi)
{
$this->mmsi = $mmsi;
return $this;
}
/**
* Get mmsi
*
* #return integer
*/
public function getMmsi()
{
return $this->mmsi;
}
/**
* Add veselMoveStatus
*
* #param \AppBundle\Entity\VesselMoveStatus $veselMoveStatus
*
* #return Vesel
*/
public function addVeselMoveStatus(\AppBundle\Entity\VesselMoveStatus $veselMoveStatus)
{
$this->veselMoveStatuses[] = $veselMoveStatus;
return $this;
}
/**
* Remove veselMoveStatus
*
* #param \AppBundle\Entity\VesselMoveStatus $veselMoveStatus
*/
public function removeVeselMoveStatus(\AppBundle\Entity\VesselMoveStatus $veselMoveStatus)
{
$this->veselMoveStatuses->removeElement($veselMoveStatus);
}
/**
* Get veselMoveStatuses
*
* #return \Doctrine\Common\Collections\Collection
*/
public function getVeselMoveStatuses()
{
return $this->veselMoveStatuses;
}
}
And is related into VesselMoveStatus entity:
namespace AppBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use AppBundle\Entity\Vesel;
/**
* #ORM\Entity(repositoryClass="AppBundle\Repository\VeselRouteRepository")
* #ORM\Table(name="vessel_position_status",indexes={
* #ORM\Index(name="position",columns={"long","lat"})
* })
*/
class VesselMoveStatus
{
/**
* #ORM\Column(type="integer")
* #ORM\Id
* #ORM\GeneratedValue(strategy="AUTO")
*/
private $id=null;
/**
* #ORM\ManyToOne(targetEntity="Vesel",inversedBy="veselMoveStatuses")
* #ORM\JoinColumn(name="vesel_id", referencedColumnName="id")
* #var Vesel
*/
private $vesel=null;
/**
* #ORM\Column(name="status",type="integer")
* #var integer|null
*/
private $status=null;
/**
* #ORM\Column(name="speed",type="integer")
* #var integer|null
*/
private $speed=null;
/**
* #ORM\Column(name="long",type="float")
* #var float|null
*/
private $logtitude=null;
/**
* #ORM\Column(name="lat",type="float")
* #var float|null
*/
private $latitude=null;
/**
* #ORM\Column(name="course",type="integer")
* #var integer|null
*/
private $course=null;
/**
* #ORM\Column(name="heading",type="integer")
* #var integer|null
*/
private $heading=null;
/**
* #ORM\Column(name="rotation",type="integer")
* #var integer|null
*/
private $rotation=null;
/**
* #ORM\Column(name="timestamp",type="datetime")
* #var Datetime|null
*/
private $timestamp=null;
public function __construct(
Vesel $vesel=null,
$status=null,
$speed=null,
$long=null,
$lat=null,
$course=null,
$heading=null,
$rotation=null,
$timestamp=null
){
$this->setVesel($vesel)
->setStatus($status)
->setSpeed($speed)
->setLogtitude($long)
->setLatitude($lat)
->setCourse($course)
->setHeading($heading)
->setRotation($rotation)
->setTimestamp($timestamp);
}
/**
* Get id
*
* #return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set mmsi
*
* #param integer $mmsi
*
* #return VesselMoveStatus
*/
public function setMmsi($mmsi)
{
$this->mmsi = $mmsi;
return $this;
}
/**
* Get mmsi
*
* #return integer
*/
public function getMmsi()
{
return $this->mmsi;
}
/**
*
* #param integer $status
* #return \AppBundle\Entity\VesselMoveStatus
*/
public function setStatus($status)
{
$this->status=$status;
return $this;
}
/**
*
* #return \AppBundle\Entity\integer|NULL
*/
public function getStatus()
{
return $this->status;
}
/**
* Set speed
*
* #param integer $speed
*
* #return VesselMoveStatus
*/
public function setSpeed($speed)
{
$this->speed = $speed;
return $this;
}
/**
* Get speed
*
* #return float
*/
public function getSpeed()
{
return $this->speed/10;
}
/**
* Set logtitude
*
* #param integer $logtitude
*
* #return VesselMoveStatus
*/
public function setLogtitude($logtitude)
{
$this->logtitude = $this->sanitizeGpsCoordinate($logtitude);
return $this;
}
/**
* Get logtitude
*
* #return float
*/
public function getLogtitude()
{
return $this->logtitude;
}
/**
* Set latitude
*
* #param integer $latitude
*
* #return VesselMoveStatus
*/
public function setLatitude($latitude)
{
$this->latitude = $this->sanitizeGpsCoordinate($latitude);
return $this;
}
/**
* Get latitude
*
* #return float
*/
public function getLatitude()
{
$latitude=$this->latitude;
return $latitude;
}
/**
* Set course
*
* #param integer $course
*
* #return VesselMoveStatus
*/
public function setCourse($course)
{
$this->course = $course;
return $this;
}
/**
* Get course
*
* #return integer
*/
public function getCourse()
{
return $this->course;
}
/**
* Set heading
*
* #param integer $heading
*
* #return VesselMoveStatus
*/
public function setHeading($heading)
{
$this->heading = $heading;
return $this;
}
/**
* Get heading
*
* #return integer
*/
public function getHeading()
{
return $this->heading;
}
/**
* Set rotation
*
* #param integer $rotation
*
* #return VesselMoveStatus
*/
public function setRotation($rotation)
{
$this->rotation = $rotation;
return $this;
}
/**
* Get rotation
*
* #return integer
*/
public function getRotation()
{
return $this->rotation;
}
/**
* Set timesptamp
*
* #param string $timesptamp
*
* #return VesselMoveStatus
*/
public function setTimestamp($timesptamp)
{
$this->timestamp = date_create_from_format("Y-m-d H:i:s.u",$timesptamp);
return $this;
}
/**
* Get timesptamp
*
* #return \DateTime
*/
public function getTimestamp()
{
return $this->timestamp;
}
/**
* Set vesel
*
* #param \AppBundle\Entity\Vesel $vesel
*
* #return VesselMoveStatus
*/
public function setVesel(\AppBundle\Entity\Vesel $vesel = null)
{
$this->vesel = $vesel;
return $this;
}
/**
* Get vesel
*
* #return \AppBundle\Entity\Vesel
*/
public function getVesel()
{
return $this->vesel;
}
/**
* Sometimes a GPS Coordinate may have the following format:
* 1,234532 if inserted as is then itn WONT be retreived correctly.
* Please use this method to sanitize the gps coordinate on setter method.
*
* #param string | float $coordinate
* #return number
*/
private function sanitizeGpsCoordinate($coordinate)
{
if(is_string($coordinate))
{
$coordinate=str_replace(',','.',$coordinate);
}
return (float)$coordinate;
}
}
The way you want to transform the data is not standard thus there is nothing generic in Doctrine to do so. But it's still very simple to achieve the objective you want.
However, IMHO the simplest solution is to use a closure to transform the result:
$result = $query->getResult();
$formatter = function($row) {
return [
"mmsi" => $row['mmsi']
"points" => [
"longtitude" => $row['logtitude'],
"latitude" => $row['latitude'],
"time" => $row['timestamp']
]
];
};
return array_map($formatter, $result);
The final array will have one element per point (veselMoveStatuses). If what you actually want is to have one element per vesel, consider changing the SELECT and adapt the formatter accordingly.
->select('v,m')
The result will be an array of Vesel objects with the veselMoveStatuses association already loaded (see this doc - section "Retrieve a CmsUser and fetch join all the phonenumbers he has").

Symfony2 - Doctrine exception: class used in the discriminator map does not exist

I am using Symfony2 with Doctrine and when I query from my controller the next error appears(it appears in the navigator when I call for the page):
Entity class 'Bdreamers\SuenoBundle\Entity\Sueno_video' used in the discriminator map of class 'Bdreamers\SuenoBundle\Entity\Sueno' does not exist.
I have one entity(superclass) called "Sueno" and two entities that extend from it(subclasses): Sueno_foto and Sueno_video.
When I load the fixtures, Doctrine works perfectly and fills the database without any issue, filling correctly the discriminator field "tipo" in the "Sueno" table. It also fills correctly the inherited entity table "Sueno_video" introducing the ID of "Sueno" and the exclusive fields of "Sueno_video"
This is the code of the entity file for "Sueno":
<?php
namespace Bdreamers\SuenoBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* #ORM\Table()
* #ORM\Entity
* #ORM\InheritanceType("JOINED")
* #ORM\DiscriminatorColumn(name="tipo", type="string")
* #ORM\DiscriminatorMap({"sueno" = "Sueno", "video" = "Sueno_video", "foto" = "Sueno_foto"})
*/
class Sueno
{
/**
* #var integer
*
* #ORM\Column(name="id", type="integer")
* #ORM\Id
* #ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* #ORM\ManyToOne(targetEntity="Bdreamers\UsuarioBundle\Entity\Usuario")
**/
private $usuario;
/**
* #ORM\ManyToMany(targetEntity="Bdreamers\SuenoBundle\Entity\Tag", inversedBy="suenos")
* #ORM\JoinTable(name="suenos_tags")
**/
private $tags;
/**
* #ORM\ManyToMany(targetEntity="Bdreamers\UsuarioBundle\Entity\Usuario", mappedBy="suenos_sigue")
* #ORM\JoinTable(name="usuarios_siguen")
**/
private $usuariosSeguidores;
/**
* #ORM\ManyToMany(targetEntity="Bdreamers\UsuarioBundle\Entity\Usuario", mappedBy="suenos_colabora")
* #ORM\JoinTable(name="usuarios_colaboran")
**/
private $usuariosColaboradores;
/**
* #var \DateTime
*
* #ORM\Column(name="fecha_subida", type="datetime")
*/
private $fechaSubida;
/**
* #var string
*
* #ORM\Column(name="titulo", type="string", length=40)
*/
private $titulo;
/**
* #var string
*
* #ORM\Column(name="que_pido", type="string", length=140)
*/
private $quePido;
/**
* #var string
*
* #ORM\Column(name="texto", type="string", length=540)
*/
private $texto;
/**
* Get id
*
* #return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set usuario
*
* #param string $usuario
* #return Sueno
*/
public function setUsuario($usuario)
{
$this->usuario = $usuario;
return $this;
}
/**
* Get usuario
*
* #return string
*/
public function getUsuario()
{
return $this->usuario;
}
public function getTags()
{
return $this->tags;
}
/**
* Set usuariosSeguidores
*
* #param string $usuariosSeguidores
* #return Sueno
*/
public function setUsuariosSeguidores($usuariosSeguidores)
{
$this->usuariosSeguidores = $usuariosSeguidores;
return $this;
}
/**
* Get usuariosSeguidores
*
* #return string
*/
public function getUsuariosSeguidores()
{
return $this->usuariosSeguidores;
}
/**
* Set usuariosColaboradores
*
* #param string $usuariosColaboradores
* #return Sueno
*/
public function setUsuariosColaboradores($usuariosColaboradores)
{
$this->usuariosColaboradores = $usuariosColaboradores;
return $this;
}
/**
* Get usuariosColaboradores
*
* #return string
*/
public function getUsuariosColaboradores()
{
return $this->usuariosColaboradores;
}
/**
* Set fechaSubida
*
* #param \DateTime $fechaSubida
* #return Sueno
*/
public function setFechaSubida($fechaSubida)
{
$this->fechaSubida = $fechaSubida;
return $this;
}
/**
* Get fechaSubida
*
* #return \DateTime
*/
public function getFechaSubida()
{
return $this->fechaSubida;
}
/**
* Set titulo
*
* #param string $titulo
* #return Sueno
*/
public function setTitulo($titulo)
{
$this->titulo = $titulo;
return $this;
}
/**
* Get titulo
*
* #return string
*/
public function getTitulo()
{
return $this->titulo;
}
/**
* Set quePido
*
* #param string $quePido
* #return Sueno
*/
public function setQuePido($quePido)
{
$this->quePido = $quePido;
return $this;
}
/**
* Get quePido
*
* #return string
*/
public function getQuePido()
{
return $this->quePido;
}
/**
* Set texto
*
* #param string $texto
* #return Sueno
*/
public function setTexto($texto)
{
$this->texto = $texto;
return $this;
}
/**
* Get texto
*
* #return string
*/
public function getTexto()
{
return $this->texto;
}
public function __construct() {
$this->usuariosColaboradores = new \Doctrine\Common\Collections\ArrayCollection();
$this->usuariosSeguidores = new \Doctrine\Common\Collections\ArrayCollection();
$this->tags = new \Doctrine\Common\Collections\ArrayCollection();
}
public function __toString()
{
return $this->getTitulo();
}
}
And this is the code for the entity Sueno_video:
<?php
namespace Bdreamers\SuenoBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* #ORM\Table()
* #ORM\Entity
*/
class Sueno_video extends Sueno
{
/**
* #var integer
*
* #ORM\Column(name="id", type="integer")
* #ORM\Id
* #ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* #var string
*
* #ORM\Column(name="link_video", type="string", length=255)
*/
private $linkVideo;
/**
* Get id
*
* #return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set linkVideo
*
* #param string $linkVideo
* #return Sueno_video
*/
public function setLinkVideo($linkVideo)
{
$this->linkVideo = $linkVideo;
return $this;
}
/**
* Get linkVideo
*
* #return string
*/
public function getLinkVideo()
{
return $this->linkVideo;
}
}
And finally the code in the controller:
public function homeAction()
{
$em = $this->getDoctrine()->getManager();
$suenos = $em->getRepository('SuenoBundle:Sueno')->findOneBy(array(
'fechaSubida' => new \DateTime('now -2 days')
));
return $this->render('EstructuraBundle:Home:home_registrado.html.twig');
}
The autoloader won't be able to resolve those class names to file paths, hence why it can't find your classes.
Changing the file and class names to SuenoVideo and SuenoFoto.

Categories