-- nettrinity <
[hidden email]> wrote
(on Saturday, 12 March 2011, 02:07 PM -0800):
> Please help me take a look at this crazy class! It implements and extends 3
> classes! What's really going on here? Does it just combine them all?
You need to read up on interfaces and extension in PHP:
http://php.net/oopBasically, you can extend a single class, which allows you to inherit
any defined methods, variables, or constants from that class. However,
you can _implement_ as many interfaces as you want. An interface
declares one or more public methods that _must_ be defined in a concrete
implementation. If you class implements several interfaces, it must then
implement the methods defined in each of those interfaces.
In the example below, getRoleId() is declared within
Zend_Acl_Role_Interface, and thus implemented in this particular class.
> class Storefront_Resource_User_Item extends
> SF_Model_Resource_Db_Table_Row_Abstract implements
> Storefront_Resource_User_Item_Interface, Zend_Acl_Role_Interface
> {
> /*... */
> public function getRoleId()
> {
> if (null === $this->getRow()->role) {
> return 'Guest';
> }
> return $this->getRow()->role;
> }
> }
--
Matthew Weier O'Phinney
Project Lead |
[hidden email]
Zend Framework |
http://framework.zend.com/PGP key:
http://framework.zend.com/zf-matthew-pgp-key.asc--
List:
[hidden email]
Info:
http://framework.zend.com/archivesUnsubscribe:
[hidden email]