-
-
Save grizzm0/3f2f332ab7b7b859f208 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Application\Service; | |
use DateTime; | |
class BarService | |
{ | |
protected $dateTime; | |
public function __construct(DateTime $dateTime) | |
{ | |
$this->dateTime = $dateTime; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Application\Factory\Service; | |
use Application\Service\BarService; | |
use DateTime; | |
use Interop\Container\ContainerInterface; | |
class BarServiceFactory | |
{ | |
/** | |
* @param ContainerInterface $container | |
* @return BarService | |
*/ | |
public function __invoke(ContainerInterface $container) | |
{ | |
return new BarService(new DateTime()); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Application\Service; | |
class FooService | |
{ | |
protected $barService; | |
protected $invokableService; | |
public function __construct(BarService $barService, InvokableService $invokableService) | |
{ | |
$this->barService = $barService; | |
$this->invokableService = $invokableService; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Application\Factory\Service; | |
use Application\Service\FooService; | |
use Interop\Container\ContainerInterface; | |
class FooServiceFactory | |
{ | |
/** | |
* @param ContainerInterface $container | |
* @return FooService | |
*/ | |
public function __invoke(ContainerInterface $container) | |
{ | |
return new FooService( | |
$container->get(Application\Service\BarService::class), | |
$container->get(Application\Service\InvokableService::class) | |
); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Application\Service; | |
class InvokableService | |
{ | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
return [ | |
'service_manager' => [ | |
'factories' => [ | |
Application\Service\FooService::class => Application\Factory\Service\FooServiceFactory::class, | |
Application\Service\BarService::class => Application\Factory\Service\BarServiceFactory::class, | |
Application\Service\InvokableService::class => Zend\ServiceManager\Factory\InvokableFactory::class, | |
], | |
], | |
]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment