Tuesday, March 5, 2013

Re: How to call a function from a different controller

As you want to use the function for multiple controllers, so there are two ways to achieve this,
1. Add this method to App controller : & use it via $this->methodname() in your controller
2. Create a component which will be used in required places, & which will be generic for that functionality. (This is the best way to use)

On Wednesday, March 6, 2013 12:22:06 AM UTC+5:30, rd...@reclutec.com wrote:
Hi, I'll explain the context of my problem:

In my project there are companies and students, companies publish job opportunities and students can apply for these.
Both companies and students inherit features from users object. So, you have users, companies and students.

In my users controller I manage things related to users: auth, send messages between users, send email notifications, etc.

My problem is:

When a student apply to a job opportunity, the app should register its apply and send a message (which is managed by users controller)

Basically I have this:

class Users extends AppController{
    ...
    function sendMessage(){
        //data is recieved by post method
    }
}

class Opportunity extends AppController{
   ...
   function registerApply(){
       //Here I should call the sendMessage() function with data
   }
}

I've readed some ideas to do this, but I don't understand how to call an external function and send POST data.

Thanks for your help.










--
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate