q2a/question2answer — pull request #156 by pupi1985 (2014-11-30 04:21:34+00:00)
Title: Added an initialization function for layers

There are basically 2 ways to initialize data in layers:

1. Override the `doctype()` function. This is conceptually wrong. It does not make sense to override that function when initializing data in a layer
1. Override the constructor. This seems like a good and correct idea. However, as the constructor gets in the theme/layer hierarchy chain, if a constructor is not properly setup, e.g., it does not have all necessary parameters defined, then the call to a parent constructor will break. Not good. So tempting developers to go this way might break initialization... even if all developers follow the rules of using all necessary parameters then an update in the core can break things again (think about the `rtl` parameter that lived for a few commits).

So no alternative is good. Now, considering the fact that we already have a `finish()` function then why not add an `initialize()` one immediately after setting up the `content`, `template`, etc members?

PS: We can later discuss the need of the `request` member considering the existance of the `qa_request()` function :)