It is possible to declare the getInstance() function from within your abstract mapper if using PHP 5.3.0:
| Code: |
abstract class App_Model_AbstractMapper {
public static function getInstance() {
$name = get_called_class();
if(is_null($name::$_instance)) {
$name::$_instance = new $name();
}
return $name::$_instance;
}
}
class App_Model_ProjectMapper extends App_Model_AbstractMapper {
protected static $_instance = null;
}
|
But you still have to declare a protected $_instance property within your child classes, not perfect but cuts down on some of the code repetition.
Very interesting tutorial, certainly helped me out with my project! The video is on the lengthy side though, and totalling 532MB! I found it more helpful downloading the video after a bit of rooting in your source. Perhaps it would be a good idea to provide a link to download the video? Just a thought!