Symfony Error when trying to get data in a relationship - php

Symfony is tormenting my head right now. I'm trying to get data from a table where the column associates a relationship with an id from another table. Thats my controller function:
/**
* #Route("/proposta/{id}", defaults={"id"=null})
*/
public function mostraAction($id) {
$model = $this->getDoctrine()->getManager();
$lista = $model->getRepository('AppBundle:Propostes')->find($id);
$em = $this->getDoctrine()->getManager();
$listaVotacions = $em->getRepository('AppBundle:Votacions')->findByIdProposta($id);
return $this->render(':Proposta:index.html.php',
array('lista'=>$lista,'listaVotacions'=>$listaVotacions));
}
That's not working, when I execute this function, my server falls and I get this error:
[ERROR] Built-in server terminated unexpectedly.
That's my class of Votacions:
<?php
namespace AppBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* Votacions
*
* #ORM\Table(name="votacions")
* #ORM\Entity(repositoryClass="AppBundle\Repository\VotacionsRepository")
*/
class Votacions
{
/**
* #var int
*
* #ORM\Column(name="id", type="integer")
* #ORM\Id
* #ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* #ORM\ManyToOne(targetEntity="Propostes")
*/
private $idProposta;
/**
* #ORM\ManyToOne(targetEntity="Usuaris")
*/
private $idUsuari;
/**
* #var bool
*
* #ORM\Column(name="vot", type="boolean", nullable=true)
*/
private $vot;
/**
* Get id
*
* #return int
*/
public function getId()
{
return $this->id;
}
/**
* Set idProposta
*
* #param integer $idProposta
*
* #return Votacions
*/
public function setIdProposta($idProposta)
{
$this->idProposta = $idProposta;
return $this;
}
/**
* Get idProposta
*
* #return int
*/
public function getIdProposta()
{
return $this->idProposta;
}
/**
* Set idUsuari
*
* #param integer $idUsuari
*
* #return Votacions
*/
public function setIdUsuari($idUsuari)
{
$this->idUsuari = $idUsuari;
return $this;
}
/**
* Get idUsuari
*
* #return int
*/
public function getIdUsuari()
{
return $this->idUsuari;
}
/**
* Set vot
*
* #param boolean $vot
*
* #return Votacions
*/
public function setVot($vot)
{
$this->vot = $vot;
return $this;
}
/**
* Get vot
*
* #return bool
*/
public function getVot()
{
return $this->vot;
}
}
And this my repository Votacions:
namespace AppBundle\Entity;
use Doctrine\ORM\EntityRepository;
class VotacionsRepository extends EntityRepository
{
public function findByIdProposta($id)
{
return $this->getEntityManager()
->createQuery(
'SELECT * FROM AppBundle:Votacions WHERE idProposta ='.$id
)->getResult();
}
}
Someone could help me :(?
Thank you so much.
Carles

Call only one time the "GetDoctrine"
-> find your lista object
-> Access idProposta from $lista object
-> the id from Proposta Entity
public function mostraAction($id) {
$model = $this->getDoctrine()->getManager();
$lista = $model->getRepository('AppBundle:Votacions')->find($id);
$lista->getIdProposta()->getId();
//..
return $this->render(':Proposta:index.html.php',
array('lista'=>$lista,'listaVotacions'=>$listaVotacions));
}

Related

Symfony and Doctrine - getDoctrine not found

I am trying to build a simple app
I have a database with a table "matches"the table structure
and i wrote this code as Entity
<?php
namespace AppBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* #ORM\Entity
* #ORM\Table(name="matches")
*/
class Match
{
/**
* #ORM\Column(type="integer")
* #ORM\Id
* #ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* #ORM\Column(type="text", length=512)
*/
private $descr;
/**
* #ORM\Column(type="string", length=255)
*/
private $team_a;
/**
* #ORM\Column(type="string", length=255)
*/
private $team_b;
/**
* #ORM\Column(type="string", length=255)
*/
private $location;
/**
* #ORM\Column(type="datetime")
*/
private $datetime;
/**
* Get id
*
* #return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set descr
*
* #param string $descr
*
* #return Match
*/
public function setDescr($descr)
{
$this->descr = $descr;
return $this;
}
/**
* Get descr
*
* #return string
*/
public function getDescr()
{
return $this->descr;
}
/**
* Set teamA
*
* #param string $teamA
*
* #return Match
*/
public function setTeamA($teamA)
{
$this->team_a = $teamA;
return $this;
}
/**
* Get teamA
*
* #return string
*/
public function getTeamA()
{
return $this->team_a;
}
/**
* Set teamB
*
* #param string $teamB
*
* #return Match
*/
public function setTeamB($teamB)
{
$this->team_b = $teamB;
return $this;
}
/**
* Get teamB
*
* #return string
*/
public function getTeamB()
{
return $this->team_b;
}
/**
* Set location
*
* #param string $location
*
* #return Match
*/
public function setLocation($location)
{
$this->location = $location;
return $this;
}
/**
* Get location
*
* #return string
*/
public function getLocation()
{
return $this->location;
}
/**
* Set datetime
*
* #param \DateTime $datetime
*
* #return Match
*/
public function setDatetime($datetime)
{
$this->datetime = $datetime;
return $this;
}
/**
* Get datetime
*
* #return \DateTime
*/
public function getDatetime()
{
return $this->datetime;
}
}
and this as controller:
<?php
namespace AppBundle\Controller;
use AppBundle\Entity\Match;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Component\HttpFoundation\Response;
class AddMatch
{
/**
* #Route("/addmatch")
*/
public function createAction()
{
$match = new Match();
$match->setDescr('Descrizione Partita');
$match->setTeamA('Squadra A');
$match->setTeamB('Squadra B');
$match->setLocation('a nice Gym');
$match->setLocation('12/12/2012');
$em = $this->getDoctrine()->getManager();
// tells Doctrine you want to (eventually) save the Product (no queries yet)
$em->persist($match);
// actually executes the queries (i.e. the INSERT query)
$em->flush();
return new Response('Saved new match with id '.$match->getId());
}
}
but it dosent work and I get Not Found
What am I missing?
I am super n00b :(
thanks for your help
You have to extend the base symfony controller:
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
class AddMatch extends Controller
{
...
}
If, for some reason, you can't extend a controller, you still can use Doctrine entity manager. In that case you need to inject the service container and then get the entity manager with
$container->get('doctrine')->getManager();
You should thoroughly read the Symfony guide on Service Container.

Semantical Error: Class MailileoBundle\Entity\Match has no field or association named getMailid

I went through all similar issues but nothing appears to solve my problem.
I've put a simple query in my MatchRepository but it throws a semantic error.
I've double(triple) checked my entity and everything looks fine. It even works fine when I pull all Matches via findAll() and then run a $match->getMailid()
The problem appears only in the MatchRepository file.
Here's the code:
Entity:
<?php
namespace MailileoBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
use MailileoBundle\Modules\DatabaseController;
use MailileoBundle\Entity\QueueItem;
use MailileoBundle\Entity\Message;
use Doctrine\Common\Collections\ArrayCollection;
/**
* #ORM\Table(name="matches")
* #ORM\Entity(repositoryClass="MailileoBundle\Entity\MatchRepository")
*/
class Match
{
/**
* #ORM\Column(type="integer")
* #ORM\Id
* #ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* #ORM\OneToMany(targetEntity="QueueItem", mappedBy="match")
*/
private $queueItems;
/**
* #ORM\OneToMany(targetEntity="Message", mappedBy="match")
*/
private $messages;
/**
* #ORM\Column(type="datetime")
*/
private $created;
/**
* #ORM\Column(type="string", length=15)
*/
private $mailid;
/**
* #ORM\Column(name="deleted", type="boolean")
*/
private $deleted;
/**
* Get id
*
* #return integer
*/
public function __construct($items, $mailid) {
foreach ($items as $item) {
$this->queueItems[] = $item;
}
$this->mailid = $mailid;
$this->created = new \DateTime("now");
$this->deleted = false;
}
public function getId()
{
return $this->id;
}
/**
* Set matchtwo
*
* #param string $matchtwo
*
* #return Match
*/
/**
* Set created
*
* #param \DateTime $created
*
* #return Match
*/
public function setCreated($created)
{
$this->created = $created;
return $this;
}
/**
* Get created
*
* #return \DateTime
*/
public function getCreated()
{
return $this->created;
}
/**
* Set mailid
*
* #param string $mailid
*
* #return Match
*/
public function setMailid($mailid)
{
$this->mailid = $mailid;
return $this;
}
/**
* Get mailid
*
* #return string
*/
public function getMailid()
{
return $this->mailid;
}
/**
* Set deleted
*
* #param boolean $deleted
*
* #return Match
*/
public function setDeleted($deleted)
{
$this->deleted = $deleted;
return $this;
}
/**
* Get deleted
*
* #return boolean
*/
public function getDeleted()
{
return $this->deleted;
}
/**
* Add queueItem
*
* #param \MailileoBundle\Entity\QueueItem $queueItem
*
* #return Match
*/
public function addQueueItem(\MailileoBundle\Entity\QueueItem $queueItem)
{
$this->queueItems[] = $queueItem;
return $this;
}
/**
* Remove queueItem
*
* #param \MailileoBundle\Entity\QueueItem $queueItem
*/
public function removeQueueItem(\MailileoBundle\Entity\QueueItem $queueItem)
{
$this->queueItems->removeElement($queueItem);
}
/**
* Get queueItems
*
* #return \Doctrine\Common\Collections\Collection
*/
public function getQueueItems()
{
return $this->queueItems;
}
/**
* Add message
*
* #param \MailileoBundle\Entity\Message $message
*
* #return Match
*/
public function addMessage(\MailileoBundle\Entity\Message $message)
{
$this->messages[] = $message;
return $this;
}
/**
* Remove message
*
* #param \MailileoBundle\Entity\Message $message
*/
public function removeMessage(\MailileoBundle\Entity\Message $message)
{
$this->messages->removeElement($message);
}
/**
* Get messages
*
* #return \Doctrine\Common\Collections\Collection
*/
public function getMessages()
{
return $this->messages;
}
}
Here's the repository:
<?php
namespace MailileoBundle\Entity;
/**
* MatchRepository
*
* This class was generated by the Doctrine ORM. Add your own custom
* repository methods below.
*/
class MatchRepository extends \Doctrine\ORM\EntityRepository
{
public function findMatchForMailId($mailid) {
$query = $this->getEntityManager()->createQuery("SELECT q FROM MailileoBundle:Match as q WHERE q.getMailid = :mailid")->setParameter('mailid', $mailid);
$item = $query->getOneOrNullResult();
return $item;
}
}
and I'm running this via:
$dbb = $this->container->get('doctrine.orm.entity_manager');
$match=$dbb->getRepository('MailileoBundle:Match')->findMatchForMailId($mailid);
Here's what I've tried so far:
clearing cache
updating entities/DB schema via console
restarting server
using q.mailid instead of getMailid()
I'm using symfony3.
Any advices? Thanks!!!
OK as Cerad had suggested I should use a property name not a getter.

Save copy of entity doctrine/symfony2

I want to keep the previous version of an entity. When the 'old' entity is updated I want to save it with the same id but with a different revision number so it looks something like this
id: 1 revision_number: 1
id: 1 revision_number: 2
This is the entity
namespace AppBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\ArrayCollection;
/**
* Form
*
* #ORM\Table()
* #ORM\Entity
* #ORM\HasLifecycleCallbacks
*/
class Form
{
/**
* #var integer
*
* #ORM\Column(name="id", type="integer")
* #ORM\Id
* #ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* #var string
*
* #ORM\Column(name="name", type="string", length=255)
*/
private $name;
/**
* #var string
*
* #ORM\Column(name="export_template", type="string", length=255, nullable = true)
*/
private $exportTemplate;
/**
* #var \DateTime
*
* #ORM\Column(name="revision", type="datetime", nullable = true)
*/
private $revision;
/**
* #var integer
*
* #ORM\Column(name="revision_number", type="integer")
* #ORM\GeneratedValue(strategy="AUTO")
*/
private $revisionNumber;
/**
* #ORM\ManyToOne(targetEntity="Client", inversedBy="forms")
* #ORM\JoinColumn(name="form_id", referencedColumnName="id")
*/
protected $client;
/**
* #ORM\OneToMany(targetEntity="Section", mappedBy="form", cascade={"persist"})
*/
protected $sections;
/**
* #ORM\OneToMany(targetEntity="Inspection", mappedBy="form")
*/
protected $inspections;
public function __construct()
{
$this->sections = new ArrayCollection();
$this->inspections = new ArrayCollection();
}
/**
* Get id
*
* #return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set name
*
* #param string $name
* #return Form
*/
public function setName($name)
{
$this->name = $name;
return $this;
}
/**
* Get name
*
* #return string
*/
public function getName()
{
return $this->name;
}
/**
* Set exportTemplate
*
* #param string $exportTemplate
* #return Form
*/
public function setExportTemplate($exportTemplate)
{
$this->exportTemplate = $exportTemplate;
return $this;
}
/**
* Get exportTemplate
*
* #return string
*/
public function getExportTemplate()
{
return $this->exportTemplate;
}
/**
* Set revision
*
* #param \DateTime $revision
* #return Form
*/
public function setRevision($revision)
{
$this->revision = $revision;
return $this;
}
/**
* Get revision
*
* #return \DateTime
*/
public function getRevision()
{
return $this->revision;
}
/**
* #param $revisionNumber
* #return Form
*/
public function setRevisionNumber($revisionNumber)
{
$this->revisionNumber = $revisionNumber;
return $this;
}
/**
* #return int
*/
public function getRevisionNumber()
{
return $this->revisionNumber;
}
/**
* Set client
*
* #param \AppBundle\Entity\Client $client
* #return Form
*/
public function setClient(\AppBundle\Entity\Client $client = null)
{
$this->client = $client;
return $this;
}
/**
* Get client
*
* #return \AppBundle\Entity\Client
*/
public function getClient()
{
return $this->client;
}
/**
* Add sections
*
* #param \AppBundle\Entity\Section $sections
* #return Form
*/
public function addSection(\AppBundle\Entity\Section $sections)
{
$this->sections[] = $sections;
return $this;
}
/**
* Remove sections
*
* #param \AppBundle\Entity\Section $sections
*/
public function removeSection(\AppBundle\Entity\Section $sections)
{
$this->sections->removeElement($sections);
}
/**
* Get sections
*
* #return \Doctrine\Common\Collections\Collection
*/
public function getSections()
{
return $this->sections;
}
/**
* Add inspections
*
* #param \AppBundle\Entity\Inspection $inspections
* #return Form
*/
public function addInspection(\AppBundle\Entity\Inspection $inspections)
{
$this->inspections[] = $inspections;
return $this;
}
/**
* Remove inspections
*
* #param \AppBundle\Entity\Inspection $inspections
*/
public function removeInspection(\AppBundle\Entity\Inspection $inspections)
{
$this->inspections->removeElement($inspections);
}
/**
* Get inspections
*
* #return \Doctrine\Common\Collections\Collection
*/
public function getInspections()
{
return $this->inspections;
}
/**
*
* #ORM\PrePersist()
*/
public function preSetDate(){
$this->revision = new \DateTime();
}
}
Is there a way I can do what I described?
I think what you may need is Loggable extension for Doctrine. Check this link:
https://github.com/Atlantic18/DoctrineExtensions/blob/master/doc/loggable.md
Loggable behavior tracks your record changes and is able to manage versions.
Using loggable behavior you can revert version from your repository with revert() method. You can find many examples on site I gave you the link above.
If you dont fancy using a 3rd party bundle for this:
your ID's will still have to be unique. If you need to track where the copy originated from then you could add a new parameter.
Once you have decided upon this, I would simply clone it, alter the revision number and add the original id if thats which way you want to go and then persist it.
class Form {
// ....
$orig_id = null;
// any getters/setters you need
// .....
}
then in the controller:
public function copyEntity($entity) {
$new_ent = clone $entity;
$new_ent->setOrigId( $entity->getId() );
$new_ent->setRevision( true ); // I would probably bin this as origId being !== null would do the same job
$this->entityManager->persist( $new_ent );
$this->entityManager->flush();
// .....
}

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.

No mapping file found for Entity class

I am quite new to Symfony2I created an Entity class in my project but I get an error. I googled the solution a lot but coudn't find it. Here is my controller
<?php
namespace IDP\Bundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use IDP\Bundle\Entity\Portfolio;
class PortfolioController extends Controller {
public function indexAction() {
$product = $this->getDoctrine()
->getRepository('IDPBundle:Portfolio')
->find(1);
return $this->render('IDPBundle:Portfolio:index.html.twig');
}
}
My Portfolio.php in Entity folder is like
<?php
namespace IDP\Bundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
/**
* IDP\Bundle\Entity\Portfolio
* #ORM\Table(name="pm_portfolios")
*/
class Portfolio
{
/**
* #var integer $id
*/
private $id;
/**
* #var integer $user_id
*/
private $user_id;
/**
* #var string $portfolio_name
*/
private $portfolio_name;
/**
* #var text $description
*/
private $description;
/**
* #var string $permalink
*/
private $permalink;
/**
* #var string $sharing_code
*/
private $sharing_code;
/**
* #var boolean $shared
*/
private $shared;
/**
* #var integer $shared_portfolio_calls
*/
private $shared_portfolio_calls;
/**
* #var integer $patentgroup_id
*/
private $patentgroup_id;
/**
* Get id
*
* #return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set user_id
*
* #param integer $userId
*/
public function setUserId($userId)
{
$this->user_id = $userId;
}
/**
* Get user_id
*
* #return integer
*/
public function getUserId()
{
return $this->user_id;
}
/**
* Set portfolio_name
*
* #param string $portfolioName
*/
public function setPortfolioName($portfolioName)
{
$this->portfolio_name = $portfolioName;
}
/**
* Get portfolio_name
*
* #return string
*/
public function getPortfolioName()
{
return $this->portfolio_name;
}
/**
* Set description
*
* #param text $description
*/
public function setDescription($description)
{
$this->description = $description;
}
/**
* Get description
*
* #return text
*/
public function getDescription()
{
return $this->description;
}
/**
* Set permalink
*
* #param string $permalink
*/
public function setPermalink($permalink)
{
$this->permalink = $permalink;
}
/**
* Get permalink
*
* #return string
*/
public function getPermalink()
{
return $this->permalink;
}
/**
* Set sharing_code
*
* #param string $sharingCode
*/
public function setSharingCode($sharingCode)
{
$this->sharing_code = $sharingCode;
}
/**
* Get sharing_code
*
* #return string
*/
public function getSharingCode()
{
return $this->sharing_code;
}
/**
* Set shared
*
* #param boolean $shared
*/
public function setShared($shared)
{
$this->shared = $shared;
}
/**
* Get shared
*
* #return boolean
*/
public function getShared()
{
return $this->shared;
}
/**
* Set shared_portfolio_calls
*
* #param integer $sharedPortfolioCalls
*/
public function setSharedPortfolioCalls($sharedPortfolioCalls)
{
$this->shared_portfolio_calls = $sharedPortfolioCalls;
}
/**
* Get shared_portfolio_calls
*
* #return integer
*/
public function getSharedPortfolioCalls()
{
return $this->shared_portfolio_calls;
}
/**
* Set patentgroup_id
*
* #param integer $patentgroupId
*/
public function setPatentgroupId($patentgroupId)
{
$this->patentgroup_id = $patentgroupId;
}
/**
* Get patentgroup_id
*
* #return integer
*/
public function getPatentgroupId()
{
return $this->patentgroup_id;
}
}
The error I am getting is
No mapping file found named 'IDP.Bundle.Entity.Portfolio.php' for class 'IDP\Bundle\Entity\Portfolio'.
Am I missing anything ?
Thanks?
You need to add #ORM\Entity to your Entity class. Try:
<?php
namespace IDP\Bundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
/**
* IDP\Bundle\Entity\Portfolio
*
* #ORM\Entity
* #ORM\Table(name="pm_portfolios")
*/
class Portfolio
{
You'll also need to add ORM mappings to each property of your Portfolio entity (see http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/annotations-reference.html#annref-column).
I got the same error and found the reason to having used annotations and yml at the same time..use only one at a time...

Categories