Adding Functionality To $this

18 views
Skip to first unread message

Steve Davies

unread,
Feb 24, 2012, 10:29:03 AM2/24/12
to Zend Framework Developers
Hi List,

In Zend Framework, is it possible to add functionality to the $this
object used within the controller?

I'm trying to create an API, defined by class files stored in a
seperate folder. So would love to be able to go:

$userDetails = $this->api->user()->getDetails();

Is this possible?

Kind regards,
Steve

James lee

unread,
Feb 24, 2012, 4:39:53 PM2/24/12
to zfdeve...@googlegroups.com
Yes ofcourse. What I normally do is, I create a My Controller Class that
extends of the Zend Controller class. Then I use My Controller instead of
Zend Controller when I create my individual controllers. Hope this makes
sense.

Hi List,

Is this possible?

Kind regards,
Steve

--
You received this message because you are subscribed to the Google Groups
"Zend Framework Developers" group.
To post to this group, send email to zfdeve...@googlegroups.com.
To unsubscribe from this group, send email to
zfdevelopers...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/zfdevelopers?hl=en.

Steve Davies

unread,
Feb 24, 2012, 4:57:07 PM2/24/12
to zfdeve...@googlegroups.com
Thanks James.

That sort of method lends itself to the My_Controller CodeIgniter offers.

Which, to be honest, I'd like to steer clear of and try and be clever
and introduce a Recourse plugin or something that creates the
functionality I need.

I'm conscious of overload... and want to try and avoid every class
extending a single common class that might become the dreaded Fat
Controller...

All the best,

Sent from my iPhone

Steve Davies
Email: sjwd...@gmail.com

Reply all
Reply to author
Forward
0 new messages