Doctrine 2 Issue - php

I am trying to learn the framework Doctrine 2. I have a Model in MySQL and implement it in Doctrine. After the implementation of the dependency between the two classes Task and Dropdown list, it doesnt operate.
My code is:
<?php
use Doctrine\Common\Collections;
use Doctrine\ORM\Mapping AS ORM;
/**
* Task
*
* #Table(name="task")
* #Entity
*/
class Task
{
/**
* #var integer
*
* #Column(name="ID", type="integer", nullable=false)
* #Id
* #GeneratedValue(strategy="IDENTITY")
*/
private $id;
/**
* #var Dropdownlist
* #ORM\OneToMany(targetEntity="Dropdownlist", mappedBy="tasks")
* #ORM\JoinColumn(name="priority", referencedColumnName="id")
*/
protected $priority;
/**
* #var string
*
* #Column(name="Label", type="string", length=45, nullable=true)
*/
private $label;
/**
* Get id
*
* #return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set priority
*
* #param integer $priority
*
* #return Task
*/
public function setPriority($priority)
{
$this->priority = $priority;
return $this;
}
/**
* Get priority
*
* #return integer
*/
public function getPriority()
{
return $this->priority;
}
/**
* Set label
*
* #param string $label
*
* #return Task
*/
public function setLabel($label)
{
$this->label = $label;
return $this;
}
/**
* Get label
*
* #return string
*/
public function getLabel()
{
return $this->label;
}
}
/**
* Dropdownlist
*
* #Table(name="dropdownlist")
* #Entity
*/
class Dropdownlist
{
/**
* #var integer
*
* #Column(name="ID", type="integer")
* #Id
* #GeneratedValue(strategy="IDENTITY")
*/
private $id;
/**
* #var string
*
* #Column(name="PriorityLabel", type="string", length=45, nullable=true)
*/
private $prioritylabel;
/*
* #var ArrayCollection
* #ORM\ManyToOne(targetEntity="Task", inversedBy="priority")
*/
protected $tasks;
/**
* Get id
*
* #return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set prioritylabel
*
* #param string $prioritylabel
*
* #return Dropdownlist
*/
public function setPrioritylabel($prioritylabel)
{
$this->prioritylabel = $prioritylabel;
return $this;
}
/**
* Get prioritylabel
*
* #return string
*/
public function getPrioritylabel()
{
return $this->prioritylabel;
}
public function getTasts(){
return $this->tasks;
}
public function __construct()
{
}
}
Problem:
The database schema is not in sync with the current mapping file.
What is the reason?
Where is the problem?
Best regards

It means your database is not in sync with your current mapping.
Run doctrine:schema:update --complete --dump-sql to see which changes need to be done. You can also run doctrine:schema:update --complete --force to deploy the changes directly.

Related

Doctrine Scheme update. Overlooking entities

I have created 2 new entities and when I run
app/console doctrine:schema:update --force
It says i am up to date and these two new entities do not get tables created.
Every other command i have found will detect entities in other bundles but none from the bundle i am working on. Example would be
app/console doctrine:mapping:info
It does not show there either.
Here is a example of one. This lives in the Entity Folder of my bundle
<?php
namespace test\OrganizationBundle\Entity;
use Symfony\Component\Validator\Constraints as Assert;
use Doctrine\ORM\Mapping as ORM;
/**
* Department
* #ORM\Entity
* #ORM\Table(name="departments")
*/
class Department
{
/**
* #var integer
*
* #ORM\Column(name="id", type="bigint", nullable=false)
* #ORM\Id
* #ORM\GeneratedValue(strategy="IDENTITY")
*/
private $id;
/**
* #var string
*
* #ORM\Column(name="name", type="string", length=50, nullable=false)
*/
private $name;
/**
* #var integer
* #ORM\Column(name="facilityId", type="int")
*
*/
private $facilityId;
/**
* #var \DateTime
* #ORM\Column(name="created", type="datetime")
*/
private $created;
/**
* #var \DateTime
* #ORM\Column(name="updated", type="datetime")
*/
private $updated;
/**
* #var array
* #ORM\ManyToMany(targetEntity="DeptTag", mappedBy="departments")
*/
private $deptTags;
public function __construct()
{
$this->deptTags = new ArrayCollection();
}
/**
* Get id
*
* #return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set name
*
* #param string $name
*
* #return Department
*/
public function setName($name)
{
$this->name = $name;
return $this;
}
/**
* Get name
*
* #return string
*/
public function getName()
{
return $this->name;
}
/**
* Set facilityId
*
* #param string $facilityId
*
* #return Department
*/
public function setFacilityId($facilityId)
{
$this->facilityId = $facilityId;
return $this;
}
/**
* Get facilityId
*
* #return string
*/
public function getFacilityId()
{
return $this->facilityId;
}
/**
* Set created
*
* #param \DateTime $created
*
* #return Department
*/
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 Department
*/
public function setUpdated($updated)
{
$this->updated = $updated;
return $this;
}
/**
* Get updated
*
* #return \DateTime
*/
public function getUpdated()
{
return $this->updated;
}
/**
* Set deptTags
*
* #param array $deptTags
*
* #return Department
*/
public function setDeptTags($deptTags)
{
$this->deptTags = $deptTags;
return $this;
}
/**
* Get deptTags
*
* #return array
*/
public function getDeptTags(DeptTag)
{
return $this->deptTags[] = $deptTag;
}
}

doctrine one-to-one relation mapping

i have two entities that i would like to map them so that when i generate crud for each entity when i want to make a new insert using Map entity to be able to select based on id from Board entity.
I've been trying to make the mapping yet .. i didn't manage not sure if i did it right or not because in mysql i don't see a foreign key after sql generation.
Board.php
<?php
namespace AppBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* Board
*
* #ORM\Table()
* #ORM\Entity(repositoryClass="AppBundle\Entity\BoardRepository")
*/
class Board
{
/**
* #var integer
*
* #ORM\Column(name="id", type="integer")
* #ORM\Id
* #ORM\GeneratedValue(strategy="AUTO")
* #ORM\ManyToOne(targetEntity="Board")
* #ORM\JoinColumns({
* #ORM\JoinColumn(name="id", referencedColumnName="BoardId")
* })
*/
private $id;
/**
* #var string
*
* #ORM\Column(name="PropertyName", type="string", length=255)
*/
private $propertyName;
/**
* #var string
*
* #ORM\Column(name="PropertyDescription", type="string", length=255)
*/
private $propertyDescription;
/**
* #var string
*
* #ORM\Column(name="PropertyPicture", type="string", length=255)
*/
private $propertyPicture;
/**
* #var string
*
* #ORM\Column(name="PropertyGlyphonic", type="string", length=255)
*/
private $propertyGlyphonic;
/**
* #var string
*
* #ORM\Column(name="PropertyPrice", type="string", length=255)
*/
private $propertyPrice;
/**
* Get id
*
* #return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set propertyName
*
* #param string $propertyName
* #return Board
*/
public function setPropertyName($propertyName)
{
$this->propertyName = $propertyName;
return $this;
}
/**
* Get propertyName
*
* #return string
*/
public function getPropertyName()
{
return $this->propertyName;
}
/**
* Set propertyDescription
*
* #param string $propertyDescription
* #return Board
*/
public function setPropertyDescription($propertyDescription)
{
$this->propertyDescription = $propertyDescription;
return $this;
}
/**
* Get propertyDescription
*
* #return string
*/
public function getPropertyDescription()
{
return $this->propertyDescription;
}
/**
* Set propertyPicture
*
* #param string $propertyPicture
* #return Board
*/
public function setPropertyPicture($propertyPicture)
{
$this->propertyPicture = $propertyPicture;
return $this;
}
/**
* Get propertyPicture
*
* #return string
*/
public function getPropertyPicture()
{
return $this->propertyPicture;
}
/**
* Set propertyGlyphonic
*
* #param string $propertyGlyphonic
* #return Board
*/
public function setPropertyGlyphonic($propertyGlyphonic)
{
$this->propertyGlyphonic = $propertyGlyphonic;
return $this;
}
/**
* Get propertyGlyphonic
*
* #return string
*/
public function getPropertyGlyphonic()
{
return $this->propertyGlyphonic;
}
/**
* Set propertyPrice
*
* #param string $propertyPrice
* #return Board
*/
public function setPropertyPrice($propertyPrice)
{
$this->propertyPrice = $propertyPrice;
return $this;
}
/**
* Get propertyPrice
*
* #return string
*/
public function getPropertyPrice()
{
return $this->propertyPrice;
}
}
Map.php
<?php
namespace AppBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* Map
*
* #ORM\Table()
* #ORM\Entity(repositoryClass="AppBundle\Entity\MapRepository")
*/
class Map
{
/**
* #var integer
*
* #ORM\Column(name="id", type="integer")
* #ORM\Id
* #ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* #var integer
* #ORM\Column(name="BoardId", type="integer")
*/
private $boardId;
/**
* #var string
*
* #ORM\Column(name="X", type="string", length=255)
*/
private $x;
/**
* #var string
*
* #ORM\Column(name="Y", type="string", length=255)
*/
private $y;
/**
* Get id
*
* #return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set boardId
*
* #param integer $boardId
* #return Map
*/
public function setBoardId($boardId)
{
$this->boardId = $boardId;
return $this;
}
/**
* Get boardId
*
* #return integer
*/
public function getBoardId()
{
return $this->boardId;
}
/**
* Set x
*
* #param string $x
* #return Map
*/
public function setX($x)
{
$this->x = $x;
return $this;
}
/**
* Get x
*
* #return string
*/
public function getX()
{
return $this->x;
}
/**
* Set y
*
* #param string $y
* #return Map
*/
public function setY($y)
{
$this->y = $y;
return $this;
}
/**
* Get y
*
* #return string
*/
public function getY()
{
return $this->y;
}
}
It seams like you haven't read the manual. It is great documentation on both Symfony.com and Doctrine-orm.readthedocs.org.
Read this article (http://symfony.com/doc/current/book/doctrine.html) and use this one as reference (http://doctrine-orm.readthedocs.org/en/latest/reference/association-mapping.html) and you will find the answer to this and many future questions.
What you basically need to do is:
class Board {
/**
* #ORM\ManyToOne(targetEntity="Map")
*/
private $map;
}

Symfony, Cannot retrieve record from table

In Symfony I cannot retrieve a record from a table using a find(), but I can using createQuery()? This is happening randomly on my tables in my project. The data just seem to become unaccessable using symfony find(), findBy() etc, but I can use dql???
Why is this happening? Has anyone ever had this happen? I cannot figure this out. Thanks for helping!
Test I've Ran: I've created a similar table using the exact same entity fields and imported the data into the table and it works absolutely fine. Why has this table just stopped responding to Symfony's request?
This Works
$dql = "SELECT co FROM WIC\CommonBundle\Entity\CustomOptions co WHERE co.account=:account_id AND co.option_field=:value";
$query = $em->createQuery($dql);
$query->setParameters(array(
'value' => 'reorder_reason',
));
$customOptionValue = $query->getResult();
echo count($customOptionValue); // equals 3
This DOES NOT Work - Exact same variables are passed in
$customOptionValue = $em->getRepository('WICCommonBundle:CustomOptions')->findBy(
array(
"option_field"=>"reorder_reason",
)
);
echo count($customOptionValue); // equals 0
Here is my CustomOptions entity:
namespace WIC\CommonBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\ArrayCollection;
use Gedmo\Mapping\Annotation as Gedmo;
use Symfony\Component\Validator\Constraints as Assert;
/**
* CustomOptions
*
* #ORM\Table(uniqueConstraints={#ORM\UniqueConstraint(name="accountFieldValueOptions", columns={"account_id", "option_value", "option_field"})})
* #ORM\Entity(repositoryClass="WIC\CommonBundle\Entity\CommonRepository")
* #Gedmo\Loggable
* #Gedmo\SoftDeleteable(fieldName="deletedAt")
* #ORM\HasLifecycleCallbacks
*/
class CustomOptions
{
/**
* #var integer $id
*
* #ORM\Column(name="id", type="integer")
* #ORM\Id
* #ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* #var string $name
*
* #Gedmo\Versioned
* #ORM\Column(name="name", type="string", length=255, unique=false, nullable=true)
*/
private $name;
/**
* #var string $option_value
*
* #Gedmo\Versioned
* #ORM\Column(name="option_value", type="string", length=255)
* #Assert\NotBlank(message="Option Value Should Not Be Blank")
*/
private $option_value;
/**
* #var string $option_field
*
* #Gedmo\Versioned
* #ORM\Column(name="option_field", type="string", length=255, unique=false, nullable=true)
*/
private $option_field;
/**
* #ORM\ManyToOne(targetEntity="WIC\AccountBundle\Entity\Account", fetch="EAGER")
* #ORM\JoinColumn(name="account_id", referencedColumnName="id", nullable=false)
* #Gedmo\Versioned
*/
protected $account;
/**
* #var datetime $created
*
* #Gedmo\Timestampable(on="create")
* #ORM\Column(type="datetime", nullable=true)
*/
private $created;
/**
* #var datetime $updated
*
* #Gedmo\Timestampable(on="update")
* #ORM\Column(type="datetime", nullable=true)
*/
private $updated;
/**
* #ORM\Column(name="deletedAt", type="datetime", nullable=true)
*/
private $deletedAt;
public function __construct()
{
}
/**
* Get id
*
* #return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set account
*
* #param \WIC\AccountBundle\Entity\Account $account
* #return InventoryLocation
*/
public function setAccount(\WIC\AccountBundle\Entity\Account $account = null)
{
$this->account = $account;
return $this;
}
/**
* Get account
*
* #return \WIC\AccountBundle\Entity\Account
*/
public function getAccount()
{
return $this->account;
}
/**
* Set created
*
* #param \DateTime $created
* #return CustomOptions
*/
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 CustomOptions
*/
public function setUpdated($updated)
{
$this->updated = $updated;
return $this;
}
/**
* Get updated
*
* #return \DateTime
*/
public function getUpdated()
{
return $this->updated;
}
/**
* Set deletedAt
*
* #param \DateTime $deletedAt
* #return CustomOptions
*/
public function setDeletedAt($deletedAt)
{
$this->deletedAt = $deletedAt;
return $this;
}
/**
* Get deletedAt
*
* #return \DateTime
*/
public function getDeletedAt()
{
return $this->deletedAt;
}
/**
* Get option_value
*
* #return string
*/
public function getOptionValue()
{
return $this->option_value;
}
/**
* Set option_value
*
* #param string $option_value
* #return CustomOptions
*/
public function setOptionValue($option_value)
{
$this->option_value = $option_value;
}
/**
* Get option_field
*
* #return string
*/
public function getOptionField()
{
return $this->option_field;
}
/**
* Set option_field
*
* #param string $option_field
* #return CustomOptions
*/
public function setOptionField($option_field)
{
$this->option_field = $option_field;
}
/**
* Get name
*
* #return string
*/
public function getName()
{
return $this->name;
}
/**
* Set name
*
* #param string $name
* #return CustomOptions
*/
public function setName($name)
{
$this->name = $name;
}
Try using the ID instead of the entire object
I.e.
$customOptionValue = $em->getRepository('WICCommonBundle:CustomOptions')->findBy(array(
"account"=>$account->getId(),
"option_field"=>"reorder_reason",
));
Edit: it's your failure to follow the coding standards expected by symfony that caused this issue for you:
Use camelCase, not underscores, for variable, function and method names
private $option_field should become private $optionField and you should adjust any functions you created to reflect this. Then your findBy array will use "optionField"=>"reorder_reason"
I see that you are using soft #Gedmo\SoftDeleteable. Can you please check if the record that exists and can not be retreived does not have deletedAt set?
Doctrine queries are ignoring record, where deletedAt is set. But lets say "not doctrine queries" would still be able to find these records.

The target-entity cannot be found in - MappingException

I have Symfony project, in which there are 2 entities - Building and Building_type. They are connected with ManyToMany uni-directional association. So, when I try to access my controller, I have this error:
The target-entity Farpost\StoreBundle\Entity\Building_type cannot be found in 'Farpost\StoreBundle\Entity\Building#building_types'.
Farpost/StoreBundle/Entity/Building.php:
namespace Farpost\StoreBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\ArrayCollection;
/**
* #ORM\Entity
*
*/
class Building
{
/**
* #var integer
*
* #ORM\Column(name="id", type="integer")
* #ORM\Id
* #ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
/**
* #var string
*
* #ORM\Column(name="alias", type="string", length=255)
*/
protected $alias;
/**
* #var string
*
* #ORM\Column(name="number", type="string", length=255)
*/
protected $number;
/**
* #ORM\ManyToMany(targetEntity="Building_type")
* #ORM\JoinTable(name="buildings_types",
* joinColumns={#ORM\JoinColumn(name="building_id", referencedColumnName="id")},
* inverseJoinColumns={#ORM\JoinColumn(name="building_type_id", referencedColumnName="id")}
* )
*/
protected $building_types;
public function __construct()
{
$this->building_types = new ArrayCollection();
}
/**
* Get id
*
* #return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set alias
*
* #param string $alias
* #return Building
*/
public function setAlias($alias)
{
$this->alias = $alias;
return $this;
}
/**
* Get alias
*
* #return string
*/
public function getAlias()
{
return $this->alias;
}
/**
* Set number
*
* #param string $number
* #return Building
*/
public function setNumber($number)
{
$this->number = $number;
return $this;
}
/**
* Get number
*
* #return string
*/
public function getNumber()
{
return $this->number;
}
/**
* Add building_types
*
* #param \Farpost\StoreBundle\Entity\Building_type $buildingTypes
* #return Building
*/
public function addBuildingType(\Farpost\StoreBundle\Entity\Building_type $buildingTypes)
{
$this->building_types[] = $buildingTypes;
return $this;
}
/**
* Remove building_types
*
* #param \Farpost\StoreBundle\Entity\Building_type $buildingTypes
*/
public function removeBuildingType(\Farpost\StoreBundle\Entity\Building_type $buildingTypes)
{
$this->building_types->removeElement($buildingTypes);
}
/**
* Get building_types
*
* #return \Doctrine\Common\Collections\Collection
*/
public function getBuildingTypes()
{
return $this->building_types;
}
/**
* Add buildings_types
*
* #param \Farpost\StoreBundle\Entity\Buildings_types $buildingsTypes
* #return Building
*/
public function addBuildingsType(\Farpost\StoreBundle\Entity\Buildings_types $buildingsTypes)
{
$this->buildings_types[] = $buildingsTypes;
return $this;
}
/**
* Remove buildings_types
*
* #param \Farpost\StoreBundle\Entity\Buildings_types $buildingsTypes
*/
public function removeBuildingsType(\Farpost\StoreBundle\Entity\Buildings_types $buildingsTypes)
{
$this->buildings_types->removeElement($buildingsTypes);
}
/**
* Get buildings_types
*
* #return \Doctrine\Common\Collections\Collection
*/
public function getBuildingsTypes()
{
return $this->buildings_types;
}
}
Farpost/StoreBundle/Entity/Building_type.php:
namespace Farpost\StoreBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
*
* #ORM\Entity
*
*/
class Building_type
{
/**
* #var integer
*
* #ORM\Column(name="id", type="integer")
* #ORM\Id
* #ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
/**
* #var string
*
* #ORM\Column(name="alias", type="string", length=255)
*/
protected $alias;
/**
* Get id
*
* #return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set alias
*
* #param string $alias
* #return Building_type
*/
public function setAlias($alias)
{
$this->alias = $alias;
return $this;
}
/**
* Get alias
*
* #return string
*/
public function getAlias()
{
return $this->alias;
}
}
Farpost/APIBundle/Controller/DefaultController.php:
public function listAction($name)
{
$repository = $this->getDoctrine()->getManager()
->getRepository('FarpostStoreBundle:Building');
$items = $repository->findAll();
$response = new Response(json_encode($items));
$response->headers->set('Content-Type', 'application/json');
return $response;
}
Also, app/console doctrine:schema:validate output is:
[Mapping] OK - The mapping files are correct.
[Database] OK - The database schema is in sync with the mapping files.
Because the name of the entity contains an underscore _ and the PSR-0 autoloader will try to find it in Farpost/StoreBundle/Entity/Building/type.php.
You need to rename your class to BuildingType and put it in Farpost/StoreBundle/Entity/BuildingType.php
Also, make sure that your composer.json has proper entries pointing to proper namespace. Mine did not, causing this error.

Symfony2 and Doctrine entity undefined method

I have this same issue as here The method name must start with either findBy or findOneBy. Undefined method Symfony? but the answers don't help.
When I run my code
<?php
namespace Map\ViewBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Map\ViewBundle\Entity\Markers;
class DefaultController extends Controller
{
public function getMarkersAction()
{
$em = $this->getDoctrine()->getManager();
$em->getRepository('MapViewBundle:Markers')
->findAllMarkers();
}
//...
}
I get exception
Undefined method 'findAllMarkers'. The method name must start with
either findBy or findOneBy!
this is my MarkersRepository file (located in Entity directory)
<?php
namespace Map\ViewBundle\Entity;
use Doctrine\ORM\EntityRepository;
class MarkersRepository extends EntityRepository
{
public function findAllMarkers() {
//this query will be different
return $this->getEntityManager()
->createQuery(
'SELECT m FROM MapViewBundle:Markers m'
)
->getResult();
}
}
and this is Markers entity class (located in Entity directory as well)
<?php
namespace Map\ViewBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* #ORM\Table(name="markers")
* #ORM\Entity(repositoryClass="Map\ViewBundle\Entity\MarkersRepository")
*/
class Markers
{
/**
* #var string
*
* #ORM\Column(name="name", type="string", length=100, nullable=false)
*/
private $name;
/**
* #var string
*
* #ORM\Column(name="description", type="string", length=500, nullable=false)
*/
private $description;
/**
* #var integer
*
* #ORM\Column(name="icon", type="integer", nullable=false)
*/
private $icon;
/**
* #var \DateTime
*
* #ORM\Column(name="post_date", type="datetime", nullable=false)
*/
private $postDate;
/**
* #var float
*
* #ORM\Column(name="lat", type="float", precision=10, scale=0, nullable=false)
*/
private $lat;
/**
* #var float
*
* #ORM\Column(name="lng", type="float", precision=10, scale=0, nullable=false)
*/
private $lng;
/**
* #var integer
*
* #ORM\Column(name="relevance_degree", type="integer", nullable=false)
*/
private $relevanceDegree;
/**
* #var string
*
* #ORM\Column(name="geohash", type="string", length=12, nullable=false)
*/
private $geohash;
/**
* #var integer
*
* #ORM\Column(name="id", type="integer")
* #ORM\Id
* #ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* #var \Doctrine\Common\Collections\Collection
*
* #ORM\ManyToMany(targetEntity="Map\ViewBundle\Entity\Tags", inversedBy="idMarkers")
* #ORM\JoinTable(name="markers_tags",
* joinColumns={
* #ORM\JoinColumn(name="id_markers", referencedColumnName="id")
* },
* inverseJoinColumns={
* #ORM\JoinColumn(name="id_tags", referencedColumnName="id")
* }
* )
*/
private $idTags;
/**
* Constructor
*/
public function __construct()
{
$this->idTags = new \Doctrine\Common\Collections\ArrayCollection();
}
/**
* Set name
*
* #param string $name
* #return Markers
*/
public function setName($name)
{
$this->name = $name;
return $this;
}
/**
* Get name
*
* #return string
*/
public function getName()
{
return $this->name;
}
/**
* Set description
*
* #param string $description
* #return Markers
*/
public function setDescription($description)
{
$this->description = $description;
return $this;
}
/**
* Get description
*
* #return string
*/
public function getDescription()
{
return $this->description;
}
/**
* Set icon
*
* #param integer $icon
* #return Markers
*/
public function setIcon($icon)
{
$this->icon = $icon;
return $this;
}
/**
* Get icon
*
* #return integer
*/
public function getIcon()
{
return $this->icon;
}
/**
* Set postDate
*
* #param \DateTime $postDate
* #return Markers
*/
public function setPostDate($postDate)
{
$this->postDate = $postDate;
return $this;
}
/**
* Get postDate
*
* #return \DateTime
*/
public function getPostDate()
{
return $this->postDate;
}
/**
* Set lat
*
* #param float $lat
* #return Markers
*/
public function setLat($lat)
{
$this->lat = $lat;
return $this;
}
/**
* Get lat
*
* #return float
*/
public function getLat()
{
return $this->lat;
}
/**
* Set lng
*
* #param float $lng
* #return Markers
*/
public function setLng($lng)
{
$this->lng = $lng;
return $this;
}
/**
* Get lng
*
* #return float
*/
public function getLng()
{
return $this->lng;
}
/**
* Set relevanceDegree
*
* #param integer $relevanceDegree
* #return Markers
*/
public function setRelevanceDegree($relevanceDegree)
{
$this->relevanceDegree = $relevanceDegree;
return $this;
}
/**
* Get relevanceDegree
*
* #return integer
*/
public function getRelevanceDegree()
{
return $this->relevanceDegree;
}
/**
* Set geohash
*
* #param string $geohash
* #return Markers
*/
public function setGeohash($geohash)
{
$this->geohash = $geohash;
return $this;
}
/**
* Get geohash
*
* #return string
*/
public function getGeohash()
{
return $this->geohash;
}
/**
* Get id
*
* #return integer
*/
public function getId()
{
return $this->id;
}
/**
* Add idTags
*
* #param \Map\ViewBundle\Entity\Tags $idTags
* #return Markers
*/
public function addIdTag(\Map\ViewBundle\Entity\Tags $idTags)
{
$this->idTags[] = $idTags;
return $this;
}
/**
* Remove idTags
*
* #param \Map\ViewBundle\Entity\Tags $idTags
*/
public function removeIdTag(\Map\ViewBundle\Entity\Tags $idTags)
{
$this->idTags->removeElement($idTags);
}
/**
* Get idTags
*
* #return \Doctrine\Common\Collections\Collection
*/
public function getIdTags()
{
return $this->idTags;
}
}
I tried clear cache and use command
php app/console doctrine:generate:entities Map
but still exception is throw. Anybody see whats wrong with my code?
Solution
Removing files: Markers.orm.yml and Tags.orm.yml from Map\ViewBundle\Resources\config\doctrine directory is the solution.
Start by verifying that you are not getting the correct repository.
$repo = $em->getRepository('MapViewBundle:Markers')
die('Repo Class ' . get_class($repo));
If you do happen to get the correct class then you have a typo.
And make sure you don't have any doctrine/markers.orm.yml or xml files hanging around.
Finally, update your question with the doctrine section in app/config/config.yml
This may sound weird but I encountered a similar issue with a custom repository function.
Try renaming your Repository function to getAllMarkers() and update the call in the controller and try again. This solved the issue for me on that occasion.

Categories