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.
No comments:
Post a Comment