Help with documentation on extending the controller #56

Closed
alscheuring opened this Issue Apr 9, 2012 · 5 comments

Projects

None yet

3 participants

@alscheuring

Hello all,

I'm still working on getting this plugin going. I'm using cakePHP 2.1.1 and I want to extend the plugin for my application. My previous question about this got me a good answer but I think it's really 1.3 specific.

So the documentation says to 'declare the class' AppUsersController. Please verify that I need to create a AppUsersController.php file and where it should go. Does it go with the rest of the Plugin's controllers or does it sit up with my AppController.php file in the main application?

I've tried both, making sure to put in the following code:
public function beforeFilter() {
parent::beforeFilter();
$this->User = ClassRegistry::init('AppUser');
}

I then try to overwrite the _getMailInstance method from the Plugin's UsersController.php but it doesn't work.

So my questions are:

  1. If I'm extending the controller, I should be able to overwrite methods that exist in the Plugin's UsersController, correct?
  2. Where should I be putting the AppUsersController.php?

Thanks for your time and patience. I really like the Plugin and I'd really like to learn how to utilize it properly.

Al

@meotimdihia

If I'm extending the controller, I should be able to overwrite methods that exist in the Plugin's UsersController, correct?
Yes. This matter is basic PHP , you should read about PHP's basics
Where should I be putting the AppUsersController.php?
You put AppUsersController.php in app/Controller/

@alscheuring

Thank you. I think I have this setup as you state but it doesn't work for me. (Fresh install of Cake 2.1.1 with Users, Search, and Utils plugins pulled from git). I'd like to extend the controller so I can adjust some Auth settings as well as get the email working without hacking the Users plugin.

in /app/Controller/AppUsersController.php -

App::uses('UsersController', 'Users.Controller');
class AppUsersController extends UsersController {

protected function _getMailInstance($config = 'smtp')
    {
    App::uses('CakeEmail', 'Network/Email');
    return new CakeEmail($config);
    }   

}

Is there any other thing you can think of that needs to be edited to make this work? Maybe something in core.php, bootstrap.php or my main AppController.php? My thoughts are that it's something obvious to a more experienced developer that I'm just not aware of.

@meotimdihia

A lot many problems you will met next to do plugin work perfect , you even must edit source plugin with your needs.
It is hard to know what you are missing. You should find out yourself.
Report if you sure 100% it is plugin's bug.

@alscheuring

Oh ok, that's all you had to say. I thought I was doing something wrong
getting into the source. Thank you for your time and help.

On 4/10/12 10:44 AM, Dien Vu wrote:

A lot many problems you will met next to do plugin work perfect , you even need edit source plugin with your needs.
It is hard to know what you need or missing. You should find out yourself.


Reply to this email directly or view it on GitHub:
#56 (comment)

@burzum
burzum commented Apr 11, 2012

Yes, this is a bug tracker not a help forum. So please report issues that are related to the code of the plugin here.

Please use IRC #cakedc, #cakephp or ask.cakephp.org or the CakePHP google group for implementation problems.

@burzum burzum closed this Apr 11, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment