I'm wondering how I could implement a design pattern that follows a few guidelines. Not difficult, but I'm having trouble visualizing it, perhaps fatigue is corroding my brain.
A singleton type class that cannot be instantiated that produces objects. The objects produced can only be created through the use of appropriate methods in the main factory class, and cannot be instantiated individually.
Eg:
I want to do this so I can set parameters in the static Factory class that can then be adhered to by all objects created by it.PHP Code:Factory::setParams($args); //success
$widget1 = Factory::makeWidget($args); //success
$widget2 = Factory::makeWidget($args); //success
$widget3 = new Widget($args); //fail
$factory = new Factory($args); //fail
Is there a more appropriate design pattern? Any advice? Thank you much in advance![]()




Reply With Quote