开发者

Make a variable in app_controller access in app_model

In my cakephp application I have some logic in beforeFilter method in app_controller.php which picks up a value.

function beforeFilter(){
    $this->oCurrentOrganisation = $organisation["Organisation"];
}

In this manner the property oCurrentOrganisation is accessible in all controllers.

I require to use this value from within the beforeSave in the app_model.php ... what is the best way to pass the variable's value.

开发者_如何学JAVA

Thanks

Regards Gabriel


does this logic have to be in beforeRender()? this is quite late to save to the model. one would need more details on what you are trying to achieve.

but either way you can always pass on stuff to the model like so

$this->Model->customVar = 'foo';

or via method (and assign the content to a variable)

$this->Model->customMethod('foo');

if you do that before save() you can count on it in beforeSave().

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜