Use Singleton parent class app-wide? #4208

Closed
mattab opened this Issue Oct 9, 2013 · 6 comments

2 participants

@mattab
Piwik Open Source Analytics member

Now that we use php 5.3, maybe it's possible to have all singletons inherit a clean Singleton abstract. Currently having to write the getInstance function is lengthy.

maybe this solution: http://stackoverflow.com/questions/3972628/creating-a-singleton-base-class-in-php-5-3?answertab=votes#tab-top

Note: we have 53 singletons in Piwik!! (because all API are singleton for example + 18 singleton in core...)

@halfdan
Piwik Open Source Analytics member

Doing this would prevent all these classes from extending another class.

We should maybe also rethink some of these singletons: http://stackoverflow.com/questions/137975/what-is-so-bad-about-singletons

@mattab
Piwik Open Source Analytics member

In 13b35fa: Refs #4208 Remove translate singleton

@mattab
Piwik Open Source Analytics member

In b6a4d25: Refs #4208 Move Plugin classes to core/Plugin for clarity

@mattab
Piwik Open Source Analytics member

In b9654b6: Refs #4208 Plugin classes moved

@mattab
Piwik Open Source Analytics member

In c782b8c: Refs #4208 refactor all singletons except the hard ones (with custom getInstance()
(some tests failing)

@mattab
Piwik Open Source Analytics member

In 7da0007: Refs #4208 refactor some singletons

@mattab mattab added this to the 2.0 - Piwik 2.0 milestone Jul 8, 2014
@sabl0r sabl0r pushed a commit to sabl0r/piwik that referenced this issue Sep 23, 2014
@mattab mattab Refs #4208 Remove translate singleton 13b35fa
@sabl0r sabl0r pushed a commit to sabl0r/piwik that referenced this issue Sep 23, 2014
@mattab mattab Refs #4208 Move Plugin classes to core/Plugin for clarity b6a4d25
@sabl0r sabl0r pushed a commit to sabl0r/piwik that referenced this issue Sep 23, 2014
@mattab mattab Refs #4208 Plugin classes moved b9654b6
@sabl0r sabl0r pushed a commit to sabl0r/piwik that referenced this issue Sep 23, 2014
@mattab mattab Refs #4208 refactor all singletons except the hard ones (with custom …
…getInstance()

(some tests failing)
c782b8c
@sabl0r sabl0r pushed a commit to sabl0r/piwik that referenced this issue Sep 23, 2014
@mattab mattab Refs #4208 refactor some singletons 7da0007
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment