Monday, September 8, 2014

Re: Make AppController variable available in pluginAppController

You're not setting the variables in the object scope but in the method scope. This means that the variables will be erased from memory when the method execution has been done. You also need to make sure that you call 
parent::beforeFilter();
In your plugin's AppController. Otherwise the general AppController's beforeFilter won't be called.


On Saturday, 6 September 2014 17:46:49 UTC+2, Sam Clauw wrote:
In the AppController, I want to put the plugin, controller and action in variables just like this:

class AppController extends Controller
{
   
public $components = array(
       
'DebugKit.Toolbar',
       
'Session'
   
);
   
   
public function beforeFilter()
   
{
        $plugin
= $this->request->params['plugin'];
        $controller
= $this->request->params['controller'];
        $action
= $this->request->params['action'];
   
}
}

Now, I've made a plugin called "CoasterCms". I thought every plugin got all the variables stored in AppController so I could get the plugin variable:

<?php

class CoasterCmsAppController extends AppController
{
    public $helpers = array(
        'Html',
        'Form',
        'Session'
    );
    
    public $components = array(
        'Session',
        'Paginator'
    );
    
    public function beforeFilter()
    {
        debug($plugin);
    }
}

However, it's not showing anything at all... What's the reason and how can I fix this?

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

No comments: