Correct, I did mean to say "from" as AppController is the parent controller.. This is one of those DUH moments where I see that I wasn't correctly calling that function from within the class. I was able to get it going with parent::sendMessage(); but obviously that isn't the "right" way..
No java here, Ruby!
Thanks for the help, appreciate the time you took to help me out.
Cheers!
John
-----Original Message-----
From: cake-php@googlegroups.com [mailto:cake-php@googlegroups.com] On Behalf Of nurvzy
Sent: Thursday, April 01, 2010 8:18 PM
To: CakePHP
Subject: Re: Methods not being inherited by AppController
You're title is misleading. You say methods aren't being inherited
by AppController, which implies you've defined methods higher up in
the chain from AppController, and you're unable to call them from
AppController. I assume you meant, Methods not being inherited FROM
AppController.
If you really mean by AppController then you're doing something wrong
(or must have a good reason) because AppController should be the *top*
of your app. you shouldn't be defining functions above AppController,
because then you're in the cake libs.
Assuming you meant you've defined a function sendMessage from withing
AppController, and you're attempting to call that function from within
another function you would do it like so:
class SomeController extends AppController {
function some_function(){
$this->sendMessage($from, $to, $subject, $msbBody);
}
}
Make sure you're using the $this reference and not just attempting to
call sendMessage() without "$this->" like you would/could in Java/Ruby/
etc,,. you have to always be explicit with PHP classes.
Note: I'm assuming you're familiar with Java because you called them
"methods" instead of "functions"..... Java was my first "real"
language as well, so I almost always call functions "methods".
Hope that helps,
Nick
How are you calling sendMessage in your other controller?
On Apr 1, 11:14 am, JNotti <jo...@blueclover.com> wrote:
> As the title implies, any methods I define within app_controller are
> showing an error as undefined when calling that method from anyone of
> my controllers. I did some searching and see that this should not be
> an issue, any thoughts?
>
> I am using version 1.2 and my AppController is located at /app/
> app_controller.php.
>
> I am calling the below method from another controller:
>
> function sendMessage($from, $to, $subject, $msgBody)
> {
>
> $this->Email->sendAs = 'text';
> $this->Email->from = $from;
> $this->Email->to = $to;
> $this->Email->subject = $subject;
> $this->Email->send($msgBody);
>
> echo "success";
>
> }//end sendMessage
>
> gives me:
>
> Fatal error: Call to undefined function sendMessage()
Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.
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+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
To unsubscribe, reply using "remove me" as the subject.
Homepage: http://www.blueclover.com | Blog: http://www.blue-ings.com | Twitter: http://twitter.com/bluecloverusa | Facebook: http://www.facebook.com/blueclover | YouTube: http://www.youtube.com/user/bluecloverstudios | Join Our Mailing List: http://visitor.constantcontact.com/manage/optin?v=001ti8yLLtrqgo7unTQ7RVsh7BIcda1iEtM
---------------------------------------------------------------------------------------------------------------------
This email transmission, including any attachments thereto, may contain information that is proprietary and confidential. The information is intended only for the use of the individual(s) or entity to whom this email has been addressed. If you are not the intended recipient, or the person responsible for delivering it to the intended recipient, you are hereby notified that any disclosure, copying, distribution or use of any of the information is strictly prohibited. If you have received this transmission in error, please let us know immediately and delete the email, including any attachments thereto, from your computer.
Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.
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+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
No comments:
Post a Comment