Last active
August 15, 2017 21:21
-
-
Save tgalopin/46e2be955762d6d68360dd455afeab70 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 Foo implements ServiceSubscriberInterface | |
{ | |
use ServiceSubscriberTrait; | |
public function do() | |
{ | |
$this->getRouter(); | |
} | |
private function getRouter(): RouterInterface | |
{ | |
return $this->container->get(__FUNCTION__); | |
} | |
} | |
trait ServiceSubscriberTrait | |
{ | |
private $container; | |
public function setContainer(ContainerInterface $container) | |
{ | |
$this->container = $container; | |
} | |
public static function getSubscribedServices() | |
{ | |
$r = new \ReflectionClass(static::class); | |
// detect methods, autowire and define services with functions names in the current service locator | |
// ... | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment