Reputation: 17
Using Propel ORM 2.0 Propel\Runtime\Collection\ObjectCollection->toJSON() is returning a json string where the first element has a key that is a pluralized version of the model's php name.
The issue is that I'm working with an existing project where the conventions use plurals already. So, in the case of the model "Users" this first element is being returned as "Userss" (with an extra 's').
For example, here's the first bit of what's being returned:
"{"Userss":[{"Id":"123",...}]}"
I've tried modifying the propel.generator.objectModel.pluralizerClass in the propel.ext file as described in the documentation (http://propelorm.org/documentation/reference/configuration-file.html) This doesn't seem to have any affect on the generated config nor does it change the behavior.
I've interrupted the code in the StandardEnglishPluralizer code and no matter what gets set in the config the StandardEnglishPluralizer is always what's used.
Is there some way to disable pluralization or create a pluralizer that doesn't pluralize and us it?
Upvotes: 0
Views: 144
Reputation: 713
With Propel2, you can create and use your own pluralizer which, if you want, would make all plural methods appear singular. However, this will result in ambiguity. For example, if you have a model with a method called getUsers, you would not know (without additional information) whether the method returns a collection or a single entity.
However, the easy way around this is to simply set the phpName attribute of the table element to "User" for the "Users" table in your schema.xml.
Upvotes: 1