Nette\PhpGenerator\ClassType::getMethod PHP Method

getMethod() public method

public getMethod ( $name ) : Method
return Method
    public function getMethod($name)
    {
        if (!isset($this->methods[$name])) {
            throw new Nette\InvalidArgumentException("Method '{$name}' not found.");
        }
        return $this->methods[$name];
    }

Usage Example

Example #1
0
 public function afterCompile(Nette\PhpGenerator\ClassType $class)
 {
     $initialize = $class->getMethod('initialize');
     $builder = $this->getContainerBuilder();
     $options = $this->config;
     unset($options['bar'], $options['blueScreen']);
     if (isset($options['logSeverity'])) {
         $res = 0;
         foreach ((array) $options['logSeverity'] as $level) {
             $res |= is_int($level) ? $level : constant($level);
         }
         $options['logSeverity'] = $res;
     }
     foreach ($options as $key => $value) {
         if ($value !== NULL) {
             $key = ($key === 'fromEmail' ? 'getLogger()->' : '$') . $key;
             $initialize->addBody($builder->formatPhp('Tracy\\Debugger::' . $key . ' = ?;', Nette\DI\Compiler::filterArguments([$value])));
         }
     }
     $logger = $builder->getDefinition($this->prefix('logger'));
     if ($logger->getFactory()->getEntity() !== 'Tracy\\Debugger::getLogger') {
         $initialize->addBody($builder->formatPhp('Tracy\\Debugger::setLogger(?);', [$logger]));
     }
     if ($this->debugMode) {
         foreach ((array) $this->config['bar'] as $item) {
             $initialize->addBody($builder->formatPhp('$this->getService(?)->addPanel(?);', Nette\DI\Compiler::filterArguments([$this->prefix('bar'), is_string($item) ? new Nette\DI\Statement($item) : $item])));
         }
         if (!$this->cliMode) {
             $initialize->addBody('if ($tmp = $this->getByType("Nette\\Http\\Session", FALSE)) { $tmp->start(); Tracy\\Debugger::dispatch(); };');
         }
     }
     foreach ((array) $this->config['blueScreen'] as $item) {
         $initialize->addBody($builder->formatPhp('$this->getService(?)->addPanel(?);', Nette\DI\Compiler::filterArguments([$this->prefix('blueScreen'), $item])));
     }
 }
All Usage Examples Of Nette\PhpGenerator\ClassType::getMethod