Created
July 17, 2012 05:58
-
-
Save madapaja/3127484 to your computer and use it in GitHub Desktop.
ray-failed-on-apc
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 | |
use Doctrine\Common\Annotations\AnnotationRegistry; | |
use Ray\Di\Di\Inject; | |
use Ray\Di\Di\Named; | |
use Ray\Di\AbstractModule; | |
use Ray\Di\Injector; | |
$loader = require __DIR__.'/vendor/autoload.php'; | |
AnnotationRegistry::registerLoader(array($loader, "loadClass")); | |
abstract class MailerInterface { | |
private $transport; | |
/** | |
* @Inject | |
* @Named("transport_type") | |
*/ | |
public function __construct($transport) | |
{ | |
$this->transport = $transport; | |
} | |
} | |
class Mailer extends MailerInterface {} | |
class NewsletterManager | |
{ | |
private $mailer; | |
/** | |
* @Inject | |
*/ | |
public function __construct(MailerInterface $mailer) | |
{ | |
$this->mailer = $mailer; | |
} | |
} | |
class NewsletterModule extends AbstractModule | |
{ | |
protected function configure() | |
{ | |
$this->bind()->annotatedWith('transport_type')->toInstance('sendmail'); | |
$this->bind('MailerInterface')->to('Mailer'); | |
} | |
} | |
$di = Injector::create([new NewsletterModule]); | |
$newsletterManager = $di->getInstance('NewsletterManager'); | |
var_dump($newsletterManager); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
error occurred with the following message.