HosipLan

Untitled

Jan 19th, 2012
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.53 KB | None | 0 0
  1. class AutowireMethodsExtension extends Nette\Config\CompilerExtension
  2. {
  3.    
  4.     public function beforeCompile()
  5.     {
  6.         $container = $this->getContainerBuilder();
  7.         foreach ($container->getDefinitions() as $def) {
  8.             if ($def->class) { // musis jeste pocitat s %%, takze prohnat pres expand()
  9.                 $refl = Nette\Reflection\ClassType::from($class);
  10.                 foreach ($refl->getMethods() as $method) {
  11.                     if (substr($method->getName(), 0, 6) === 'inject') {
  12.                         $def->addSetup($method->getName(), array('...'));
  13.                     }
  14.                 }
  15.             }
  16.         }
  17.     }
  18.  
  19. }
Advertisement
Add Comment
Please, Sign In to add comment