Created
September 26, 2014 10:36
-
-
Save immutef/fbd4996cd6380a0e4480 to your computer and use it in GitHub Desktop.
Abstract Service Definitions with Constructor Arguments
This file contains 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 | |
abstract class AbstractService | |
{ | |
public function __construct(SomeService $someService) | |
{ | |
// ... | |
} | |
} |
This file contains 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 | |
class ConcreteService extends AbstractService | |
{ | |
public function __construct(SomeService $someService, AnotherService $anotherService) | |
{ | |
parent::__construct($someService); | |
// ... | |
} | |
} |
This file contains 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
<?xml version="1.0" encoding="UTF-8" ?> | |
<container xmlns="http://symfony.com/schema/dic/services" | |
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"> | |
<parameters> | |
<parameter key="service.abstract.class">AbstractService</parameter> | |
<parameter key="service.concrete.class">ConcreteService</parameter> | |
</parameters> | |
<services> | |
<service id="service.abstract" class="%service.abstract.class%" abstract="true"> | |
<argument type="service" id="some.service"/> | |
</service> | |
<service id="service.concrete" class="%service.concrete.class%" parent="service.abstract"> | |
<argument type="service" id="another.service"/> | |
</service> | |
</services> | |
</container> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment