Created
March 13, 2020 17:06
-
-
Save ChrisDBrown/3b193a2d4608b08e51d931f069b0f905 to your computer and use it in GitHub Desktop.
Quick autowire named config argument
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 JsonSerializer implements SerializerInterface | |
{ | |
public function serialize() | |
{ | |
// do json | |
} | |
} |
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 LoanSerializer | |
{ | |
/** SerializerInterface **/ | |
private $serializer; | |
public function __construct(SerializerInterface $serializer) | |
{ | |
$this->serializer = $serializer; | |
} | |
} |
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 | |
interface SerializerInterface | |
{ | |
public function serialize(); | |
} |
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
LoanSerializer: | |
autowire: true | |
arguments: | |
$serializer: JsonSerializer |
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 XmlSerializer implements SerializerInterface | |
{ | |
public function serialize() | |
{ | |
// do xml | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment