Doctrine 2 - ORM
  1. Doctrine 2 - ORM
  2. DDC-2184

[GH-530] Singular form of generated methods should end with 'y' when property ends with 'ies'

    Details

    • Type: Improvement Improvement
    • Status: Awaiting Feedback
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 2.3
    • Fix Version/s: None
    • Component/s: Tools
    • Security Level: All
    • Labels:
      None

      Description

      In Doctrine 2.3 the 'add' and 'remove' methods in oneToMany associations have another problem (in earlier versions like 2.2 this worked correct). The singular form is not correctly detected if the property ends with 'ies' like 'entries' which should be transformed to 'entry'.
      I have this YAML definition:

      Archive:
        type: entity
        fields:
          id:
            id: true
            type: integer
            unsigned: false
            nullable: false
            generator:
              strategy: IDENTITY
        oneToMany:
          entries:
            targetEntity: Entry
            mappedBy: archive
      

      This generates these methods:

      public function addEntrie(\Entry $entries) { ... }
      public function removeEntrie(\Entry $entries) { ... }
      

      Because in the EntityGenerator only the plural 's' is removed. It would be nice if an ending of 'ies' could be replaced by 'y'. So that we get these methods

      public function addEntry(\Entry $entries) { ... }
      public function removeEntry(\Entry $entries) { ... }
      

      My fork already has the changes https://github.com/naitsirch/doctrine-orm2/commit/a3adfccb4927d61da7debae46ed0fff61e4212f8
      I have opened a pull request here https://github.com/doctrine/doctrine2/pull/530

        Issue Links

          Activity

            People

            • Assignee:
              Benjamin Eberlei
              Reporter:
              Benjamin Eberlei
            • Votes:
              1 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated: