Piwik_FrontController question


(ambertch) #1

Hey All,

I’m looking through piwik to get a sense of how it’s constructed (excuse my noobness), I was curious why in index.php you guys designed it to call:

$controller = Piwik_FrontController::getInstance();

which leads to a use of magic constants I don’t understand the purpose of?

$c = CLASS;
self::$instance = new $c();
return self::$instance;

Why doesn’t FrontController just have a constructor, and index.php call $controller = new Piwik_FrontController() instead of going through a few lines to end up calling the default constructor?

Thanks!
Ambert


(vipsoft) #2

It’s a design pattern known as Singleton.


(ambertch) #3

Got it, thanks man!