In the behaviors section of CakePHP documentation the following statement can be found:
Since behaviors are shared across all the model instances that use them, it’s a good practice to store the settings per alias/model name that is using the behavior.
That means that settings should be managed this way:
$this->settings[$Model->alias] = array(
'option1_key' => 'option1_default_value',
'option2_key' => 'option2_default_value',
...
);
I have developed a behavior that uses a protected property _files to store information between callbacks. Does the above statement implies that I should also index _files by model name as $settings?
Thanks!!
Yes, that implies that 🙂
unless you want all model instances access to the very same content, of course.