lets say i have a service:
namespace Helloworld\\Service;
class GreetingService
{
public function getGreeting()
{
if(date(\"H\") <= 11)
To add something to @yechabbis answer:
The factory pattern for the ServiceConfiguration
is indeed for complex infrastructure or simply to not use closures
/ callable functions
inside the configuration. This is for two reasons:
Setting up the factory pattern inside getServiceConfig
is nice, clean and fast. No classes are instantiated but will so upon call of the service-key. If, however, you set up services using the closure pattern or callable function, then those classes will always be instantiated, upon every single request!
This probably is just an example thing, but the code you've shown would also best be served as a ViewHelper