php - CakePHP: Use function from Plugin Controller in Main Controller -


this should simple i've spent on hour trying figure out help.

i've got cakephp plugin, usermgmt, controller located here:

./app/plugin/usermgmt/controller/userscontroller.php 

i'm trying call function, useridfromusernameandpassword(), in controller 1 of main controllers using like:

$userid = $this->userscontroller->useridfromusernameandpassword( 'user@host.com','pass' ); 

what need import/include/initialize able working?

i've tried various import statements such app::uses('userscontroller', 'usermgmt.controller'); @ top of file, haven't gotten anywhere.

thanks!

short answer: use oop , extend other controller. understanding of mvc. not supposed use method of controller inside controller, in cakephp should done component. can shared between controllers. check cakephp book.

also name of plugin , method name indicate bad plugin. sounds did not know auth component of cakephp. again, check book authcomponent. you want custom authentication adapter.

if user logged in can id calling $this->auth->user('id'). read chapter auth. if want done user plugin check out: cakedc users


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -