Doctrine 2 - ORM
  1. Doctrine 2 - ORM
  2. DDC-1268

generate:entities creates bad method names with OneToMany

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 2.1
    • Fix Version/s: 2.1.1
    • Component/s: Tools
    • Security Level: All
    • Labels:
      None
    • Environment:
      Ubuntu 11.04, PHP 5.3.5, Symfony 2.0 RC4

      Description

      Hi. I noticed a minor bug in the generate:entities console task. I've got a Region entity that had the following property:

      /**
       * @ORM\OneToMany(targetEntity="District", mappedBy="region")
       */
      private $districts;
      
      public function __construct()
      {
          $this->districts = new ArrayCollection();
      }
      

      When I ran the generate:entities task it created the following methods:

      /**
       * Add districts
       *
       * @param Fenix\StudyBundle\Entity\District $districts
       */
      public function addDistricts(\Fenix\StudyBundle\Entity\District $districts)
      {
          $this->districts[] = $districts;
      }
      
      /**
       * Get districts
       *
       * @return Doctrine\Common\Collections\Collection 
       */
      public function getDistricts()
      {
          return $this->districts;
      }
      

      The second method's name is correct, but what about addDistricts? Since it allows me to add a single District entity it should be as follows:

      /**
       * Add district
       *
       * @param Fenix\StudyBundle\Entity\District $district
       */
      public function addDistrict(\Fenix\StudyBundle\Entity\District $district)
      {
          $this->districts[] = $district;
      }
      

      In other words, the term after "add" (as well as the parameter's name) should be the entity's name, not the property's one.

        Activity

          People

          • Assignee:
            Benjamin Eberlei
            Reporter:
            Alessandro Desantis
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: