0

例子:

$Model->Behaviors->load('Some.Behaviour', $options);

// Now how do I get $options back from the model?

有没有办法得到$options$Model->actsAs仍然是空的。

4

1 回答 1

1

这些选项存储在settingsBehavior 本身的属性中。您可以通过以下方式获得它:

$this->Behaviors->Behavior->settings[''];

例如:

$this->Behaviors->load('Containable', array('hello' => 'world'));
var_dump($this->Behaviors->Containable->settings);

将返回:

array (size=2)
  'priority' => int 10
  '' => 
    array (size=4)
      'recursive' => boolean true
      'notices' => boolean true
      'autoFields' => boolean true
      'hello' => string 'world' (length=5)

如您所见,“hello world 选项”就在底部。

于 2015-05-28T21:27:59.763 回答