I have a global object in my main controllers that I need to pass to a plugin controller, how do I achieve this and resolve th开发者_如何学Goe scope?
If you speaking about global object placed in app_controller.php of your application, then it's very easy, because all plugins extend AppController class. Basically what would be your code:
class AppController extends Controller {
function beforeFilter(){
$this->global_object = ... //the global object instance.
}
}
Then because your plugin's AppControler extends applications's AppController you can access it in all plugin's controllers functions. For example:
class YourPluginAppController extends AppController {
function doSomethingWithGlobalObject(){
$this->global_object->doSome();//
}
}
Hope this is what you asked.
精彩评论