I may be having a basic OOP doubt but I believe it's worth sharing after hours of search.
For example: From my controller I want to retrieve data from an Entity Class... however, this class extends an Abstract that MAY do the job. Controller:
//Setting info to object
$entity->setName( 'Peter' );
$entity->setAnge( 33 );
//Retriving data in array
$data = $entity->getData();
Class Entity:
class Entity extends EntityAbstract {
private $name;
private $age;
public function getData() {
return parent::getData($this);//I'm passing this object to get its methods (or vars)
}
public class setName() { ... }
public class getName() { ... }
public class setAge() { ... }
public class getAge() { ... }
}
And finally Abrastract Class (Parent).
class EntityAbstract {
public function getData( $entity ) {
//I'm not sure how to proceed here.
//I've listed all child's methods, but can't list class_vars (private)
$methods = get_class_methods( $entity );
// By listing method, I've tryed to use a regular expression to
// identify methods starting with 'get' and then setting an array but
// this didn't work... I got a memory exceed error.
$data = array();
// foreach() loop
$data[ $valueKey ] = $entity->$methodGetOfEach();
return $data;
}
}
If perhaps there's some zend method to help me with this, but I believe this is a matter of OOP and PHP knowledge to solve.
Thanks for any suggestion.