本文整理汇总了PHP中Nette\PhpGenerator\ClassType::addDocument方法的典型用法代码示例。如果您正苦于以下问题:PHP ClassType::addDocument方法的具体用法?PHP ClassType::addDocument怎么用?PHP ClassType::addDocument使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Nette\PhpGenerator\ClassType
的用法示例。
在下文中一共展示了ClassType::addDocument方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: afterCompile
public function afterCompile(Nette\PhpGenerator\ClassType $class)
{
$initialize = $class->getMethod('initialize');
$container = $this->getContainerBuilder();
if ($this->debugMode && $this->config['debugger']) {
$initialize->addBody($container->formatPhp('?;', array(new Nette\DI\Statement('@Tracy\\Bar::addPanel', array(new Nette\DI\Statement('Nette\\Bridges\\DITracy\\ContainerPanel'))))));
}
foreach (array_filter($container->findByTag('run')) as $name => $on) {
$initialize->addBody('$this->getService(?);', array($name));
}
if (!empty($this->config['accessors'])) {
$definitions = $container->getDefinitions();
ksort($definitions);
foreach ($definitions as $name => $def) {
if (Nette\PhpGenerator\Helpers::isIdentifier($name)) {
$type = $def->getImplement() ?: $def->getClass();
$class->addDocument("@property {$type} \${$name}");
}
}
}
}
示例2: doDecorate
/**
* @param PhpNamespace $namespace
* @param ClassType $class
* @param Column $column
* @return void
*/
public function doDecorate(Column $column, ClassType $class, PhpNamespace $namespace)
{
$column->setPhpDoc($doc = new PhpDoc());
// Annotation
$doc->setAnnotation('@property');
// Type
if ($column->isNullable()) {
$doc->setType($this->getRealType($column) . '|NULL');
} else {
$doc->setType($this->getRealType($column));
}
// Variable
$doc->setVariable(Helpers::camelCase($column->getName()));
// Defaults
if ($column->getDefault() !== NULL) {
$doc->setDefault($this->getRealDefault($column));
}
// Enum
if (!empty($enum = $column->getEnum())) {
$doc->setEnum(Strings::upper($column->getName()));
}
// Relations
if (($key = $column->getForeignKey()) !== NULL) {
// Find foreign entity table
$ftable = $column->getTable()->getDatabase()->getForeignTable($key->getReferenceTable());
// Update type to Entity name
$doc->setType($this->resolver->resolveEntityName($ftable));
$doc->setRelation($relDoc = new PhpRelDoc());
if ($use = $this->getRealUse($ftable, $namespace)) {
$namespace->addUse($use);
}
$relDoc->setType('???');
$relDoc->setEntity($this->resolver->resolveEntityName($ftable));
$relDoc->setVariable('???');
}
// Append phpDoc to class
$class->addDocument((string) $column->getPhpDoc());
}
示例3: afterCompile
public function afterCompile(Nette\PhpGenerator\ClassType $class)
{
$initialize = $class->methods['initialize'];
$container = $this->getContainerBuilder();
$config = $this->getConfig($this->defaults);
// debugger
foreach (array('email', 'editor', 'browser', 'strictMode', 'maxLen', 'maxDepth', 'showLocation', 'scream') as $key) {
if (isset($config['debugger'][$key])) {
$initialize->addBody('Nette\\Diagnostics\\Debugger::$? = ?;', array($key, $config['debugger'][$key]));
}
}
if ($container->parameters['debugMode']) {
if ($config['container']['debugger']) {
$config['debugger']['bar'][] = 'Nette\\DI\\Diagnostics\\ContainerPanel';
}
foreach ((array) $config['debugger']['bar'] as $item) {
$initialize->addBody($container->formatPhp('Nette\\Diagnostics\\Debugger::getBar()->addPanel(?);', Nette\DI\Compiler::filterArguments(array(is_string($item) ? new Nette\DI\Statement($item) : $item))));
}
foreach ((array) $config['debugger']['blueScreen'] as $item) {
$initialize->addBody($container->formatPhp('Nette\\Diagnostics\\Debugger::getBlueScreen()->addPanel(?);', Nette\DI\Compiler::filterArguments(array($item))));
}
}
if (!empty($container->parameters['tempDir'])) {
$initialize->addBody('Nette\\Caching\\Storages\\FileStorage::$useDirectories = ?;', array($this->checkTempDir($container->expand('%tempDir%/cache'))));
}
foreach ((array) $config['forms']['messages'] as $name => $text) {
$initialize->addBody('Nette\\Forms\\Rules::$defaultMessages[Nette\\Forms\\Form::?] = ?;', array($name, $text));
}
if ($config['session']['autoStart'] === 'smart') {
$initialize->addBody('$this->getByType("Nette\\Http\\Session")->exists() && $this->getByType("Nette\\Http\\Session")->start();');
} elseif ($config['session']['autoStart']) {
$initialize->addBody('$this->getByType("Nette\\Http\\Session")->start();');
}
if ($config['latte']['xhtml']) {
$initialize->addBody('Nette\\Utils\\Html::$xhtml = ?;', array(TRUE));
}
if (isset($config['security']['frames']) && $config['security']['frames'] !== TRUE) {
$frames = $config['security']['frames'];
if ($frames === FALSE) {
$frames = 'DENY';
} elseif (preg_match('#^https?:#', $frames)) {
$frames = "ALLOW-FROM {$frames}";
}
$initialize->addBody('header(?);', array("X-Frame-Options: {$frames}"));
}
foreach ($container->findByTag('run') as $name => $on) {
if ($on) {
$initialize->addBody('$this->getService(?);', array($name));
}
}
if (!empty($config['container']['accessors'])) {
$definitions = $container->definitions;
ksort($definitions);
foreach ($definitions as $name => $def) {
if (Nette\PhpGenerator\Helpers::isIdentifier($name)) {
$type = $def->implement ?: $def->class;
$class->addDocument("@property {$type} \${$name}");
}
}
}
$initialize->addBody("@header('Content-Type: text/html; charset=utf-8');");
$initialize->addBody('Nette\\Utils\\SafeStream::register();');
}