Inflector Class Info:
- Class Declaration:
- class Inflector extends Object
- File name:
- cake/libs/inflector.php
- Summary:
- Pluralize and singularize English words. Inflector pluralizes and singularizes English nouns. Used by Cake's naming conventions throughout the framework. Test with $i = new Inflector(); $i->test();
- Class Inheritance
- package
- cake
- subpackage
- cake.cake.libs
- link
- http://book.cakephp.org/view/491/Inflector
Properties:
Show/Hide parent properties
| protected | _log | Log object |
| public | pluralRules | List of pluralization rules in the form of pattern => replacement. |
| public | singularRules | List of singularization rules in the form of pattern => replacement. |
Method Summary:
Show/Hide parent methods
| public | cakeError( $method, $messages = array ( ) ) |
| public | camelize( $lowerCaseAndUnderscoredWord ) |
| public | classify( $tableName ) |
| public | __construct( ) |
| public | dispatchMethod( $method, $params = array ( ) ) |
| public | getInstance( ) |
| public | humanize( $lowerCaseAndUnderscoredWord ) |
| protected | __initSingularRules( ) |
| public | log( $msg, $type = 2 ) |
| public | Object( ) |
| protected | _persist( $name, $return, $object, $type = NULL ) |
| public | pluralize( $word ) |
| public | requestAction( $url, $extra = array ( ) ) |
| protected | _savePersistent( $name, $object ) |
| protected | _set( $properties = array ( ) ) |
| public | singularize( $word ) |
| public | slug( $string, $replacement = '_' ) |
| public | _stop( $status = 0 ) |
| public | tableize( $className ) |
| public | toString( ) |
| public | underscore( $camelCasedWord ) |
| public | variable( $string ) |
cakeError
topUsed to report user friendly errors.
If there is a file app/error.php or app/app_error.php this file will be loaded
error.php is the AppError class it should extend ErrorHandler class.
- Parameters:
-
$method string Method to be called in the error class (AppError or ErrorHandler classes) required (no default) $messages array Message that is to be displayed by the error class optional array ( ) - Method defined in class:
- Object
- Method defined in file:
- cake/libs/object.php on line 189
- return
- error message
- access
- public
camelize
topReturns the given lower_case_and_underscored_word as a CamelCased word.
- Parameters:
-
$lowerCaseAndUnderscoredWord required (no default) - Method defined in class:
- Inflector
- Method defined in file:
- cake/libs/inflector.php on line 416
- return
- string Camelized word. LikeThis.
- access
- public
- static
- link
- http://book.cakephp.org/view/572/Class-methods
classify
topReturns Cake model class name ("Person" for the database table "people".) for given database table.
- Parameters:
-
$tableName string Name of database table to get class name for required (no default) - Method defined in class:
- Inflector
- Method defined in file:
- cake/libs/inflector.php on line 465
- return
- string Class name
- access
- public
- static
- link
- http://book.cakephp.org/view/572/Class-methods
__construct
topClass constructor, overridden in descendant classes.
- Method defined in class:
- Object
- Method defined in file:
- cake/libs/object.php on line 63
dispatchMethod
topCalls a method on this object with the given parameters. Provides an OO wrapper
for call_user_func_array, and improves performance by using straight method calls
in most cases.
- Parameters:
-
$method string Name of the method to call required (no default) $params array Parameter list to use when calling $method optional array ( ) - Method defined in class:
- Object
- Method defined in file:
- cake/libs/object.php on line 113
- return
- mixed Returns the result of the method call
- access
- public
getInstance
topGets a reference to the Inflector object instance
- Method defined in class:
- Inflector
- Method defined in file:
- cake/libs/inflector.php on line 127
- return
- object
- access
- public
humanize
topReturns the given underscored_word_group as a Human Readable Word Group.
(Underscores are replaced by spaces and capitalized following words.)
- Parameters:
-
$lowerCaseAndUnderscoredWord required (no default) - Method defined in class:
- Inflector
- Method defined in file:
- cake/libs/inflector.php on line 441
- return
- string Human-readable string
- access
- public
- static
- link
- http://book.cakephp.org/view/572/Class-methods
__initSingularRules
topInitializes singular inflection rules.
- Method defined in class:
- Inflector
- Method defined in file:
- cake/libs/inflector.php on line 275
- return
- void
- access
- protected
log
topAPI for logging events.
- Parameters:
-
$msg string Log message required (no default) $type integer Error type constant. Defined in app/config/core.php. optional 2 - Method defined in class:
- Object
- Method defined in file:
- cake/libs/object.php on line 150
- return
- boolean Success of log write
- access
- public
Object
topA hack to support __construct() on PHP 4
Hint: descendant classes have no PHP4 class_name() constructors,
so this constructor gets called first and calls the top-layer __construct()
which (if present) should call parent::__construct()
- Method defined in class:
- Object
- Method defined in file:
- cake/libs/object.php on line 53
- return
- Object
_persist
topChecks for a persistent class file, if found file is opened and true returned
If file is not found a file is created and false returned
If used in other locations of the model you should choose a unique name for the persistent file
There are many uses for this method, see manual for examples
- Parameters:
-
$name string name of the class to persist required (no default) $return required (no default) $object string the object to persist required (no default) $type optional NULL - Method defined in class:
- Object
- Method defined in file:
- cake/libs/object.php on line 219
- return
- boolean Success
- access
- protected
- todo
- add examples to manual
pluralize
topReturn $word in plural form.
- Parameters:
-
$word string Word in singular required (no default) - Method defined in class:
- Inflector
- Method defined in file:
- cake/libs/inflector.php on line 234
- return
- string Word in plural
- access
- public
- static
- link
- http://book.cakephp.org/view/572/Class-methods
requestAction
topCalls a controller's method from any location.
- Parameters:
-
$url mixed String or array-based url. required (no default) $extra array if array includes the key "return" it sets the AutoRender to true. optional array ( ) - Method defined in class:
- Object
- Method defined in file:
- cake/libs/object.php on line 86
- return
- mixed Boolean true or false on success/failure, or contents of rendered action if 'return' is set in $extra.
- access
- public
_savePersistent
topYou should choose a unique name for the persistent file
There are many uses for this method, see manual for examples
- Parameters:
-
$name string name used for object to cache required (no default) $object object the object to persist required (no default) - Method defined in class:
- Object
- Method defined in file:
- cake/libs/object.php on line 247
- return
- boolean true on save, throws error if file can not be created
- access
- protected
_set
topAllows setting of multiple properties of the object in a single line of code.
- Parameters:
-
$properties array An associative array containing properties and corresponding values. optional array ( ) - Method defined in class:
- Object
- Method defined in file:
- cake/libs/object.php on line 169
- return
- void
- access
- protected
singularize
topReturn $word in singular form.
- Parameters:
-
$word string Word in plural required (no default) - Method defined in class:
- Inflector
- Method defined in file:
- cake/libs/inflector.php on line 370
- return
- string Word in singular
- access
- public
- static
- link
- http://book.cakephp.org/view/572/Class-methods
slug
topReturns a string with all spaces converted to underscores (by default), accented
characters converted to non-accented characters, and non word characters removed.
- Parameters:
-
$string string required (no default) $replacement string optional '_' - Method defined in class:
- Inflector
- Method defined in file:
- cake/libs/inflector.php on line 493
- return
- string
- access
- public
- static
- link
- http://book.cakephp.org/view/572/Class-methods
_stop
topStop execution of the current script
- Parameters:
-
$status optional 0 - Method defined in class:
- Object
- Method defined in file:
- cake/libs/object.php on line 139
- return
- void
- access
- public
tableize
topReturns corresponding table name for given model $className. ("people" for the model class "Person").
- Parameters:
-
$className string Name of class to get database table name for required (no default) - Method defined in class:
- Inflector
- Method defined in file:
- cake/libs/inflector.php on line 453
- return
- string Name of the database table for given class
- access
- public
- static
- link
- http://book.cakephp.org/view/572/Class-methods
toString
topObject-to-string conversion.
Each class can override this method as necessary.
- Method defined in class:
- Object
- Method defined in file:
- cake/libs/object.php on line 73
- return
- string The name of this class
- access
- public
underscore
topReturns the given camelCasedWord as an underscored_word.
- Parameters:
-
$camelCasedWord string Camel-cased word to be "underscorized" required (no default) - Method defined in class:
- Inflector
- Method defined in file:
- cake/libs/inflector.php on line 428
- return
- string Underscore-syntaxed version of the $camelCasedWord
- access
- public
- static
- link
- http://book.cakephp.org/view/572/Class-methods
variable
topReturns camelBacked version of an underscored string.
- Parameters:
-
$string string required (no default) - Method defined in class:
- Inflector
- Method defined in file:
- cake/libs/inflector.php on line 477
- return
- string in variable form
- access
- public
- static
- link
- http://book.cakephp.org/view/572/Class-methods