Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Symfony2 generating getters/setters

I am developing an application using Symfony2. The problem comes when trying to generate getters an setters for BalidatzeTaldea.php entity using sudo php app/console doctrine:generate:entities Anotatzailea/AnotatzaileaBundle The code for the entity is the following:

<?php

namespace Anotatzailea\AnotatzaileaBundle\Entity;

use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\ArrayCollection;

/**
 *
 *@ORM\Table(name="BalidatzeTaldea")
 *@ORM\Entity
 */
class BalidatzeTaldea
{
    /**
     * @var integer $BalTalId
     *
     * @ORM\Column(name="BalTalId", type="integer")
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    private $BalTalId;

    /**
     * @ORM\OneToMany(targetEntity="Erabiltzailea", mappedBy="BalidatzeTaldea")
     */
    protected $Erabiltzaileak;

    /**
     * @var integer $ErabGaitasuna
     *
     * @ORM\Column(name="ErabGaitasuna", type="integer")
     */
    private $ErabGaitasuna;

    public function __construct()
    {
        $this->Erabiltzaileak = new ArrayCollection();
    }

}

Getters/Setters for other entities in the Entity folder are generated correctly. What can I do? Thanks.

like image 210
Haritz Avatar asked Mar 07 '12 12:03

Haritz


2 Answers

I know this is old, but i just ran into this problem myself...

I had

/*
 * @ORM\Id
 * @ORM\Column(type="integer")
 * @ORM\GeneratedValue(strategy="AUTO")
 */
protected $id;

And the setter/getter generation did not work. Changed it to

/**
 * @ORM\Id
 * @ORM\Column(type="integer")
 * @ORM\GeneratedValue(strategy="AUTO")
 */
protected $id;

And it worked! The extra * in the first line of the comment seems to change something. I also noticed it changed my IDE syntax highlighting.

From your code, it seems you had the two * in the first comment line, but if someone else stumbles on this, i hope it helps.

like image 166
jaudette Avatar answered Oct 22 '22 13:10

jaudette


Delete the cache directory --> "app/cache" and try again

like image 4
Ardavan Kalhori Avatar answered Oct 22 '22 13:10

Ardavan Kalhori