TranslateBehavior Class Info:

Class Declaration:

class TranslateBehavior extends ModelBehavior

File name:
cake/libs/model/behaviors/translate.php
Description:

Translate behavior

Class Inheritance

ModelBehavior Object

Properties:

Show/Hide parent properties
  • mapMethods array

    Allows the mapping of preg-compatible regular expressions to public or private methods in this class, where the array key is a /-delimited regular expression, and the value is a class method. Similar to the functionality of the findBy* / findAllBy* magic methods.

  • runtime array

    Used for runtime configuration of model

  • settings array

    Contains configuration settings for use with individual model objects. This is used because if multiple models use this Behavior, each will use the same object instance. Individual model settings should be stored as an associative array, keyed off of the model name.

_addToWhitelist

top

If $model's whitelist property is non-empty, $field will be added to it. Note: this method should only be used in beforeValidate or beforeSave to ensure that it only modifies the whitelist for the current save operation. Also make sure you explicitly set the value of the field which you are allowing.

Parameters:
  • object $model required

    Model using this behavior

  • string $field required

    Field to be added to $model's whitelist

Method defined in:
cake/libs/model/model_behavior.php on line 196
Access

protected

Return

void

afterDelete

top

afterDelete Callback

Parameters:
  • Model $model required

    Model the callback was run on.

Method defined in:
cake/libs/model/behaviors/translate.php on line 342
Return

void

Access

public

afterFind

top

afterFind Callback

Parameters:
  • Model $model required

    Model find was run on

  • array $results required

    Array of model results.

  • boolean $primary required

    Did the find originate on $model.

Method defined in:
cake/libs/model/behaviors/translate.php on line 219
Return

array Modified results

Access

public

afterSave

top

afterSave Callback

Parameters:
  • Model $model required

    Model the callback is called on

  • boolean $created required

    Whether or not the save created a record.

Method defined in:
cake/libs/model/behaviors/translate.php on line 298
Return

void

Access

public

beforeDelete

top

Before delete callback

Parameters:
  • object $model required

    Model using this behavior

  • boolean $cascade optional true

    If true records that depend on this record will also be deleted

Method defined in:
cake/libs/model/model_behavior.php on line 135
Return

mixed False if the operation should abort. Any other result will continue.

Access

public

beforeFind

top

beforeFind Callback

Parameters:
  • Model $model required

    Model find is being run on.

  • array $query required

    Array of Query parameters.

Method defined in:
cake/libs/model/behaviors/translate.php on line 92
Return

array Modified query

Access

public

beforeSave

top

Before save callback

Parameters:
  • object $model required

    Model using this behavior

Method defined in:
cake/libs/model/model_behavior.php on line 116
Return

mixed False if the operation should abort. Any other result will continue.

Access

public

beforeValidate

top

beforeValidate Callback

Parameters:
  • Model $model required

    Model invalidFields was called on.

Method defined in:
cake/libs/model/behaviors/translate.php on line 263
Return

boolean

Access

public

bindTranslation

top

Bind translation for fields, optionally with hasMany association for fake field

Parameters:
  • $model required

  • $fields required

  • boolean $reset optional true

    with field or array(field1, field2=>AssocName, field3)

Method defined in:
cake/libs/model/behaviors/translate.php on line 410
Return

bool

cakeError

top

Used 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:
  • string $method required

    Method to be called in the error class (AppError or ErrorHandler classes)

  • array $messages optional array ( )

    Message that is to be displayed by the error class

Method defined in:
cake/libs/object.php on line 187
Return

error message

Access

public

cleanup

top

Cleanup Callback unbinds bound translations and deletes setting information.

Parameters:
  • Model $model required

    Model being detached.

Method defined in:
cake/libs/model/behaviors/translate.php on line 78
Return

void

Access

public

__construct

top

Class constructor, overridden in descendant classes.

Method defined in:
cake/libs/object.php on line 54

dispatchMethod

top

Overrides Object::dispatchMethod to account for PHP4's broken reference support

Parameters:
  • $model required

  • $method required

  • $params optional array ( )

Method defined in:
cake/libs/model/model_behavior.php on line 161
See

Object::dispatchMethod

Access

public

Return

mixed

_getLocale

top

Get selected locale for model

Parameters:
  • Model $model required

    Model the locale needs to be set/get on.

Method defined in:
cake/libs/model/behaviors/translate.php on line 355
Return

mixed string or false

Access

protected

log

top

Convience method to write a message to CakeLog. See CakeLog::write() for more information on writing to logs.

Parameters:
  • string $msg required

    Log message

  • integer $type optional 2

    Error type constant. Defined in app/config/core.php.

Method defined in:
cake/libs/object.php on line 148
Return

boolean Success of log write

Access

public

Object

top

A 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:
cake/libs/object.php on line 43
Return

Object

onError

top

DataSource error callback

Parameters:
  • object $model required

    Model using this behavior

  • string $error required

    Error generated in DataSource

Method defined in:
cake/libs/model/model_behavior.php on line 152
Access

public

_persist

top

Checks 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:
  • string $name required

    name of the class to persist

  • $return required

  • string $object required

    the object to persist

  • $type optional NULL

Method defined in:
cake/libs/object.php on line 218
Return

boolean Success

Access

protected

Todo

add examples to manual

requestAction

top

Calls a controller's method from any location. Can be used to connect controllers together or tie plugins into a main application. requestAction can be used to return rendered views or fetch the return value from controller actions.

Parameters:
  • mixed $url required

    String or array-based url.

  • array $extra optional array ( )

    if array includes the key "return" it sets the AutoRender to true.

Method defined in:
cake/libs/object.php on line 80
Return

mixed Boolean true or false on success/failure, or contents of rendered action if 'return' is set in $extra.

Access

public

_savePersistent

top

You should choose a unique name for the persistent file

There are many uses for this method, see manual for examples

Parameters:
  • string $name required

    name used for object to cache

  • object $object required

    the object to persist

Method defined in:
cake/libs/object.php on line 247
Return

boolean true on save, throws error if file can not be created

Access

protected

_set

top

Allows setting of multiple properties of the object in a single line of code. Will only set properties that are part of a class declaration.

Parameters:
  • array $properties optional array ( )

    An associative array containing properties and corresponding values.

Method defined in:
cake/libs/object.php on line 166
Return

void

Access

protected

setup

top

Callback

$config for TranslateBehavior should be array( 'fields' => array('field_one', 'field_two' => 'FieldAssoc', 'field_three'))

With above example only one permanent hasMany will be joined (for field_two as FieldAssoc)

$config could be empty - and translations configured dynamically by bindTranslation() method

Parameters:
  • Model $model required

    Model the behavior is being attached to.

  • array $config optional array ( )

    Array of configuration information.

Method defined in:
cake/libs/model/behaviors/translate.php on line 55
Return

mixed

Access

public

_stop

top

Stop execution of the current script. Wraps exit() making testing easier.

Parameters:
  • $status optional 0

Method defined in:
cake/libs/object.php on line 135
Return

void

Access

public

toString

top

Object-to-string conversion. Each class can override this method as necessary.

Method defined in:
cake/libs/object.php on line 64
Return

string The name of this class

Access

public

translateModel

top

Get instance of model for translations.

If the model has a translateModel property set, this will be used as the class name to find/use. If no translateModel property is found 'I18nModel' will be used.

Parameters:
  • Model $model required

    Model to get a translatemodel for.

Method defined in:
cake/libs/model/behaviors/translate.php on line 378
Return

object

Access

public

unbindTranslation

top

Unbind translation for fields, optionally unbinds hasMany association for fake field

Parameters:
  • object $model required

    instance of model

  • mixed $fields optional NULL

    string with field, or array(field1, field2=>AssocName, field3), or null for unbind all original translations

Method defined in:
cake/libs/model/behaviors/translate.php on line 483
Return

bool