{281} - 3.4.6 Custom Inflections

Cake's naming conventions can be really nice–you can name your database table big_boxes, your model BigBox, your controller BigBoxesController, and everything just works together automatically. The way CakePHP knows how to tie things together is by inflecting the words between their singular and plural forms.

There are occasions (especially for our non-english speaking friends) where you may run into situations where CakePHP's inflector (the class that pluralizes, singularizes, camelCases, and under_scores) might not work as you'd like. If CakePHP won't recognize your Foci or Fish, editing the custom inflections configuration file is where you can tell CakePHP about your special cases. This file is found in /app/config/inflections.php.

In this file, you will find six variables. Each allows you to fine-tune CakePHP inflection behavior.

inflections.php Variable Description
$pluralRules This array contains regular expression rules for pluralizing special cases. The keys of the array are patterns, and the values are replacements.
$uninflectedPlural An array containing words that do not need to be modified in order to be plural (mass nouns, etc.).
$irregularPlural An array containing words and their plurals. The keys of the array contain the singular form, the values, plural forms. This array should be used to store words that don’t follow rules defined in $pluralRules.
$singularRules Same as with $pluralRules, only this array holds rules that singularize words.
$uninflectedSingular Same as with $uninflectedPlural, only this array holds words that have no singular form. This is set equal to $uninflectedPlural by default.
$irregularSingular Same as with $irregularPlural, only with words in singular form.

{1652} - 3.4.6 Custom Inflections

Cake's naming conventions can be really nice - you can name your database table big_boxes, your model BigBox, your controller BigBoxesController, and everything just works together automatically. The way CakePHP knows how to tie things together is by inflecting the words between their singular and plural forms.

There are occasions (especially for our non-English speaking friends) where you may run into situations where CakePHP's inflector (the class that pluralizes, singularizes, camelCases, and under_scores) might not work as you'd like. If CakePHP won't recognize your Foci or Fish, editing the custom inflections configuration file is where you can tell CakePHP about your special cases. This file is found in /app/config/inflections.php.

In this file, you will find six variables. Each allows you to fine-tune CakePHP inflection behavior.

inflections.php Variable Description
$pluralRules This array contains regular expression rules for pluralizing special cases. The keys of the array are patterns, and the values are replacements.
$uninflectedPlural An array containing words that do not need to be modified in order to be plural (mass nouns, etc.).
$irregularPlural An array containing words and their plurals. The keys of the array contain the singular form, the values, plural forms. This array should be used to store words that don’t follow rules defined in $pluralRules.
$singularRules Same as with $pluralRules, only this array holds rules that singularize words.
$uninflectedSingular Same as with $uninflectedPlural, only this array holds words that have no singular form. This is set equal to $uninflectedPlural by default.
$irregularSingular Same as with $irregularPlural, only with words in singular form.

Differences

Lines: 1-10Lines: 1-10
 <title>Custom Inflections</title> <title>Custom Inflections</title>
 <p> <p>
- Cake's naming conventions can be really niceyou can name your database table big_boxes, your model BigBox, your controller BigBoxesController, and everything just works together automatically. The way CakePHP knows how to tie things together is by <em>inflecting</em> the words between their singular and plural forms. + Cake's naming conventions can be really nice - you can name your database table big_boxes, your model BigBox, your controller BigBoxesController, and everything just works together automatically. The way CakePHP knows how to tie things together is by <em>inflecting</em> the words between their singular and plural forms.
 </p> </p>
 <p> <p>
- There are occasions (especially for our non-english speaking friends) where you may run into situations where CakePHP's inflector (the class that pluralizes, singularizes, camelCases, and under_scores) might not work as you'd like. If CakePHP won't recognize your Foci or Fish, editing the custom inflections configuration file is where you can tell CakePHP about your special cases. This file is found in /app/config/inflections.php. + There are occasions (especially for our non-English speaking friends) where you may run into situations where CakePHP's inflector (the class that pluralizes, singularizes, camelCases, and under_scores) might not work as you'd like. If CakePHP won't recognize your Foci or Fish, editing the custom inflections configuration file is where you can tell CakePHP about your special cases. This file is found in /app/config/inflections.php.
 </p> </p>
 <p> <p>
  In this file, you will find six variables. Each allows you to fine-tune CakePHP inflection behavior.  In this file, you will find six variables. Each allows you to fine-tune CakePHP inflection behavior.
 </p> </p>
Lines: 65-69Lines: 65-68
  Same as with $irregularPlural, only with words in singular form.  Same as with $irregularPlural, only with words in singular form.
  </td>  </td>
  </tr>  </tr>
 </table> </table>