Skip to content

Instantly share code, notes, and snippets.

@ChrisDBrown
Created March 13, 2020 17:06
Show Gist options
  • Save ChrisDBrown/3b193a2d4608b08e51d931f069b0f905 to your computer and use it in GitHub Desktop.
Save ChrisDBrown/3b193a2d4608b08e51d931f069b0f905 to your computer and use it in GitHub Desktop.
Quick autowire named config argument
<?php
class JsonSerializer implements SerializerInterface
{
public function serialize()
{
// do json
}
}
<?php
class LoanSerializer
{
/** SerializerInterface **/
private $serializer;
public function __construct(SerializerInterface $serializer)
{
$this->serializer = $serializer;
}
}
<?php
interface SerializerInterface
{
public function serialize();
}
LoanSerializer:
autowire: true
arguments:
$serializer: JsonSerializer
<?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