/** * @param Method $initialize * @param $config * @param $method * @param $defaults */ private function registerSelectBox(Method $initialize, $config, $method, $defaults) { $codes = count($config['codes']) == 0 ? $defaults : (array) $config['codes']; $list = array(); foreach ($codes as $code) { $lowercase = strtolower($code); $list[$lowercase] = $config['prefix'] . $lowercase; } $initialize->addBody(GenericSelectBox::class . '::register(?,?);', array($method, $list)); }
private function addCollapsePathsToTracy(Method $init) { $blueScreen = 'Tracy\\Debugger::getBlueScreen()'; $commonDirname = dirname(Nette\Reflection\ClassType::from('Doctrine\\Common\\Version')->getFileName()); $init->addBody($blueScreen . '->collapsePaths[] = ?;', array(dirname(Nette\Reflection\ClassType::from('Kdyby\\Doctrine\\Exception')->getFileName()))); $init->addBody($blueScreen . '->collapsePaths[] = ?;', array(dirname(dirname(dirname(dirname($commonDirname)))))); // this should be vendor/doctrine foreach ($this->proxyAutoloaders as $dir) { $init->addBody($blueScreen . '->collapsePaths[] = ?;', array($dir)); } }
private function generateExceptionBody(PhpGenerator\Method $method, $destination, \Exception $exception) { $method->addBody("Assert::exception(function () {\n" . "\t\$this->checkAction(?);\n" . '}, ?);', [$destination, get_class($exception)]); if ($exception instanceof \Nette\Application\BadRequestException) { $method->addBody("Assert::same(?, \$this->getReturnCode());", [$exception->getCode()]); } return $method; }
private function setupCustom(Method $initialize) { $config = $this->getConfig(); if (isset($config['custom']['parameters'])) { if (!is_array($config['custom']['parameters'])) { throw new \RuntimeException('Invalid custom parameters structure'); } foreach ($config['custom']['parameters'] as $name => $value) { $initialize->addBody('\\VrtakCZ\\NewRelic\\Tracy\\Custom\\Parameters::addParameter(?, ?);', [$name, $value]); } } if (isset($config['custom']['tracers'])) { if (!is_array($config['custom']['tracers'])) { throw new \RuntimeException('Invalid custom tracers structure'); } foreach ($config['custom']['tracers'] as $function) { $initialize->addBody('\\VrtakCZ\\NewRelic\\Tracy\\Custom\\Tracers::addTracer(?);', [$function]); } } }