Re: How to call a function from another controlle?

2012-09-07 Thread Chris Thompson
If it's logic used by multiple Controllers it should go in a Component.

-- 
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en-US.




Re: How to call a function from another controlle?

2012-09-07 Thread datgs
Can this work for Cake 1.3?

On Thursday, September 6, 2012 12:23:39 PM UTC+7, andrewperk wrote:

 I do this:

 ?php
 // Loads in the TestController from the Test plugin Controller package
 App::uses('TestController', 'Test.Controller');

 class AppController extends Controller {

 public function beforeFilter() {
 // Instantiate the TestController
 // Call your method
 $Test = ClassRegistry::init('TestController');
 $Test-ping();
 }
 }

 On Wednesday, September 5, 2012 4:06:39 PM UTC-7, Salines wrote:

 eg I have a plugin called Test, and the class named TestController, where 
 I have a ping function  , public function ping() {...}

 how can I call the ping function from app controller beforeFilter 
 function?

 public function beforeFilter(){
  // call Plugin/Test/TestController/ping() ???
 }

 Thanx




-- 
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en-US.




Re: How to call a function from another controlle?

2012-09-06 Thread Salines
Thank you,

function which I want to call,
is used to refresh expired token

-- 
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en-US.




Re: How to call a function from another controlle?

2012-09-05 Thread Jonathan Sundquist
Create an app controller and have both controllers extend it. Then move
your ping function into the app controller.

- The cold winds are rising
On Sep 5, 2012 6:06 PM, Salines nikola.parad...@gmail.com wrote:

 eg I have a plugin called Test, and the class named TestController, where
 I have a ping function  , public function ping() {...}

 how can I call the ping function from app controller beforeFilter function?

 public function beforeFilter(){
  // call Plugin/Test/TestController/ping() ???
 }

 Thanx


  --
 You received this message because you are subscribed to the Google Groups
 CakePHP group.
 To post to this group, send email to cake-php@googlegroups.com.
 To unsubscribe from this group, send email to
 cake-php+unsubscr...@googlegroups.com.
 Visit this group at http://groups.google.com/group/cake-php?hl=en-US.




-- 
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en-US.




Re: How to call a function from another controlle?

2012-09-05 Thread Chetan Patel
Make a Common function in /your_app_name/lib/Cake/basics.php


function ping_common($params){

 return $something;
}



Then You should use it in anywhere in your application.

function ping()
{
$response_something = ping_common($params);
}
-- 
Thanks  Regards

Chetan Patel

-- 
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en-US.




Re: How to call a function from another controlle?

2012-09-05 Thread andrewperk
I do this:

?php
// Loads in the TestController from the Test plugin Controller package
App::uses('TestController', 'Test.Controller');

class AppController extends Controller {

public function beforeFilter() {
// Instantiate the TestController
// Call your method
$Test = ClassRegistry::init('TestController');
$Test-ping();
}
}

On Wednesday, September 5, 2012 4:06:39 PM UTC-7, Salines wrote:

 eg I have a plugin called Test, and the class named TestController, where 
 I have a ping function  , public function ping() {...}

 how can I call the ping function from app controller beforeFilter function?

 public function beforeFilter(){
  // call Plugin/Test/TestController/ping() ???
 }

 Thanx




-- 
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en-US.