Skip to content

Instantly share code, notes, and snippets.

@juriansluiman
Created June 18, 2014 14:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save juriansluiman/61ec10c218f4359d905d to your computer and use it in GitHub Desktop.
Save juriansluiman/61ec10c218f4359d905d to your computer and use it in GitHub Desktop.
<?php
class MyFactory implements FactoryInterface
{
public function createService()
{
$adapter = // get adapter based on config;
$service = new Service($adapter);
return $service;
}
}
<?php
class Service
{
protected $adapter;
protected $logger;
public function __construct(AdapterInterface $adapter)
{
$this->adapter = $adapter;
}
public function setLogger(LoggerInterface $logger)
{
$this->logger = $logger;
if ($this->adapter instanceof LoggerAwareInterface) {
$this->adapter->setLogger($logger);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment