• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP PhpGenerator\Helpers类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中Nette\PhpGenerator\Helpers的典型用法代码示例。如果您正苦于以下问题:PHP Helpers类的具体用法?PHP Helpers怎么用?PHP Helpers使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Helpers类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: generate

 /**
  * @param Database $database
  */
 public function generate(Database $database)
 {
     foreach ($database->getTables() as $table) {
         // Create namespace and inner class
         $namespace = new PhpNamespace($this->resolver->resolveRepositoryNamespace($table));
         $class = $namespace->addClass($this->resolver->resolveRepositoryName($table));
         // Detect extends class
         if (($extends = $this->config->get('repository.extends')) !== NULL) {
             $namespace->addUse($extends);
             $class->setExtends($extends);
         }
         // Save file
         $this->generateFile($this->resolver->resolveRepositoryFilename($table), (string) $namespace);
     }
     // Generate abstract base class
     if ($this->config->get('repository.extends') !== NULL) {
         // Create abstract class
         $namespace = new PhpNamespace($this->config->get('repository.namespace'));
         $class = $namespace->addClass(Helpers::extractShortName($this->config->get('repository.extends')));
         $class->setAbstract(TRUE);
         // Add extends from ORM/Repository
         $extends = $this->config->get('nextras.orm.class.repository');
         $namespace->addUse($extends);
         $class->setExtends($extends);
         // Save file
         $this->generateFile($this->resolver->resolveFilename(Helpers::extractShortName($this->config->get('repository.extends')), $this->config->get('repository.folder')), (string) $namespace);
     }
 }
开发者ID:minetro,项目名称:normgen,代码行数:31,代码来源:RepositoryGenerator.php


示例2: afterCompile

 public function afterCompile(ClassType $class)
 {
     $container = $this->getContainerBuilder();
     $config = $this->getConfig($this->defaults);
     if ($config['panel'] && $container->parameters['debugMode']) {
         $init = $class->methods['initialize'];
         $init->addBody(Helpers::format('Foowie\\Cron\\Diagnostics\\Panel::register($this->getByType(?), $this->getByType(?));', 'Foowie\\Cron\\ICron', 'Nette\\Http\\Request'));
     }
 }
开发者ID:foowie,项目名称:cron,代码行数:9,代码来源:CronExtension.php


示例3: write

 /**
  * @param string $content
  * @param string $id
  */
 protected function write($content, $id)
 {
     $content = is_string($content) ? $content : Code\Helpers::dump($content);
     $file = $this->logDir . '/curl_' . @date('Y-m-d-H-i-s') . '_' . $id . '.dat';
     foreach (Nette\Utils\Finder::findFiles("curl_*_{$id}.dat")->in($this->logDir) as $item) {
         /** @var \SplFileInfo $item */
         $file = $item->getRealpath();
     }
     if (!@file_put_contents($file, $content, FILE_APPEND)) {
         Debugger::log("Logging to {$file} failed.");
     }
 }
开发者ID:noikiy,项目名称:Curl,代码行数:16,代码来源:FileLogger.php


示例4: afterCompile

 public function afterCompile(Code\ClassType $class)
 {
     $container = $this->getContainerBuilder();
     if ($eventManager = $container->getByType('Kdyby\\Events\\EventManager')) {
         $methodName = 'createService' . ucfirst($this->name) . '__command';
         $method = $class->methods[$methodName];
         $body = explode(';', substr(trim($method->getBody()), 0, -1));
         $return = array_pop($body);
         $body[] = Code\Helpers::format(PHP_EOL . '$service->setEventManager($this->getService(?))', $eventManager);
         $body[] = $return;
         $method->setBody(implode(';', $body) . ';');
     }
 }
开发者ID:dotblue,项目名称:nextras-migrations-command,代码行数:13,代码来源:MigrationsExtension.php


示例5: afterCompile

    public function afterCompile(Nette\PhpGenerator\ClassType $class)
    {
        $config = $this->getConfig($this->defaults);
        Nette\Utils\Validators::assertField($config, 'enabled', 'boolean');
        Nette\Utils\Validators::assertField($config, 'accessToken', 'string');
        Nette\Utils\Validators::assertField($config, 'roomName', 'string');
        Nette\Utils\Validators::assertField($config, 'filters', 'array');
        if (!$config['enabled']) {
            return;
        }
        unset($config['enabled']);
        $init = $class->methods['initialize'];
        $init->addBody(Nette\PhpGenerator\Helpers::format('
			$logger = new Vysinsky\\HipChat\\Bridges\\Tracy\\Logger(?, ?, ?, ?);
			Tracy\\Debugger::setLogger($logger);
		', $config['accessToken'], $config['roomName'], $config['filters'], $config['linkFactory']));
    }
开发者ID:vysinsky,项目名称:hipchat-logger,代码行数:17,代码来源:Extension.php


示例6: generate

 /**
  * @param Database $database
  */
 public function generate(Database $database)
 {
     foreach ($database->getTables() as $table) {
         // Create namespace and inner class
         $namespace = new PhpNamespace($this->resolver->resolveEntityNamespace($table));
         $class = $namespace->addClass($this->resolver->resolveEntityName($table));
         // Detect extends class
         if (($extends = $this->config->get('entity.extends')) === NULL) {
             $extends = $this->config->get('nextras.orm.class.entity');
         }
         // Add namespace and extends class
         $namespace->addUse($extends);
         $class->setExtends($extends);
         // Add table columns
         foreach ($table->getColumns() as $column) {
             if ($this->config->get('generator.entity.exclude.primary')) {
                 if ($column->isPrimary()) {
                     continue;
                 }
             }
             foreach ($this->decorators as $decorator) {
                 $decorator->doDecorate($column, $class, $namespace);
             }
         }
         // Save file
         $this->generateFile($this->resolver->resolveEntityFilename($table), (string) $namespace);
     }
     // Generate abstract base class
     if ($this->config->get('entity.extends') !== NULL) {
         // Create abstract class
         $namespace = new PhpNamespace($this->config->get('entity.namespace'));
         $class = $namespace->addClass(Helpers::extractShortName($this->config->get('entity.extends')));
         $class->setAbstract(TRUE);
         // Add extends from ORM/Entity
         $extends = $this->config->get('nextras.orm.class.entity');
         $namespace->addUse($extends);
         $class->setExtends($extends);
         // Save file
         $this->generateFile($this->resolver->resolveFilename(Helpers::extractShortName($this->config->get('entity.extends')), $this->config->get('entity.folder')), (string) $namespace);
     }
 }
开发者ID:minetro,项目名称:normgen,代码行数:44,代码来源:EntityGenerator.php


示例7: 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}");
             }
         }
     }
 }
开发者ID:vladimirslevercz,项目名称:alena,代码行数:21,代码来源:DIExtension.php


示例8: addBody

 /**
  * @return self
  */
 public function addBody($statement, array $args = NULL)
 {
     $this->body .= (func_num_args() > 1 ? Helpers::formatArgs($statement, $args) : $statement) . "\n";
     return $this;
 }
开发者ID:re1la2pse,项目名称:GromesProjekt,代码行数:8,代码来源:Method.php


示例9: formatPhp

 /**
  * Formats PHP statement.
  * @return string
  * @internal
  */
 public function formatPhp($statement, $args)
 {
     array_walk_recursive($args, function (&$val) {
         if ($val instanceof Statement) {
             $val = self::literal($this->formatStatement($val));
         } elseif ($val === $this) {
             $val = self::literal('$this');
         } elseif ($val instanceof ServiceDefinition) {
             $val = '@' . current(array_keys($this->getDefinitions(), $val, TRUE));
         }
         if (!is_string($val)) {
             return;
         } elseif (substr($val, 0, 2) === '@@') {
             $val = substr($val, 1);
         } elseif (substr($val, 0, 1) === '@') {
             $pair = explode('::', $val, 2);
             $name = $this->getServiceName($pair[0]);
             if (isset($pair[1]) && preg_match('#^[A-Z][A-Z0-9_]*\\z#', $pair[1], $m)) {
                 $val = $this->getDefinition($name)->getClass() . '::' . $pair[1];
             } else {
                 if ($name === self::THIS_CONTAINER) {
                     $val = '$this';
                 } elseif ($name === $this->currentService) {
                     $val = '$service';
                 } else {
                     $val = $this->formatStatement(new Statement(['@' . self::THIS_CONTAINER, 'getService'], [$name]));
                 }
                 $val .= isset($pair[1]) ? PhpHelpers::formatArgs('->?', [$pair[1]]) : '';
             }
             $val = self::literal($val);
         }
     });
     return PhpHelpers::formatArgs($statement, $args);
 }
开发者ID:ondrejmirtes,项目名称:di,代码行数:39,代码来源:ContainerBuilder.php


示例10: __toString

 /**
  * @return string PHP code
  */
 public function __toString() : string
 {
     $uses = [];
     asort($this->uses);
     foreach ($this->uses as $alias => $name) {
         $useNamespace = Helpers::extractNamespace($name);
         if ($this->name !== $useNamespace) {
             if ($alias === $name || substr($name, -(strlen($alias) + 1)) === '\\' . $alias) {
                 $uses[] = "use {$name};";
             } else {
                 $uses[] = "use {$name} as {$alias};";
             }
         }
     }
     $body = ($uses ? implode("\n", $uses) . "\n\n" : '') . implode("\n", $this->classes);
     if ($this->bracketedSyntax) {
         return 'namespace' . ($this->name ? ' ' . $this->name : '') . " {\n\n" . Strings::indent($body) . "\n}\n";
     } else {
         return ($this->name ? "namespace {$this->name};\n\n" : '') . $body;
     }
 }
开发者ID:kukulich,项目名称:php-generator,代码行数:24,代码来源:PhpNamespace.php


示例11: 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();');
 }
开发者ID:jurasm2,项目名称:nette,代码行数:63,代码来源:NetteExtension.php


示例12: addTrait

 /**
  * @param  string
  * @return ClassType
  */
 public function addTrait(string $name) : ClassType
 {
     return $this->addNamespace(Helpers::extractNamespace($name))->addTrait(Helpers::extractShortName($name));
 }
开发者ID:kukulich,项目名称:php-generator,代码行数:8,代码来源:PhpFile.php


示例13: processConnection

 protected function processConnection($name, array $defaults, $isDefault = FALSE)
 {
     $builder = $this->getContainerBuilder();
     $config = $this->resolveConfig($defaults, $this->connectionDefaults, $this->managerDefaults);
     if ($isDefault) {
         $builder->parameters[$this->name]['dbal']['defaultConnection'] = $name;
     }
     if (isset($defaults['connection'])) {
         return $this->prefix('@' . $defaults['connection'] . '.connection');
     }
     // config
     $configuration = $builder->addDefinition($this->prefix($name . '.dbalConfiguration'))->setClass('Doctrine\\DBAL\\Configuration')->addSetup('setResultCacheImpl', array($this->processCache($config['resultCache'], $name . '.dbalResult')))->addSetup('setSQLLogger', array(new Statement('Doctrine\\DBAL\\Logging\\LoggerChain')))->addSetup('setFilterSchemaAssetsExpression', array($config['schemaFilter']))->setAutowired(FALSE)->setInject(FALSE);
     // types
     Validators::assertField($config, 'types', 'array');
     $schemaTypes = $dbalTypes = array();
     foreach ($config['types'] as $dbType => $className) {
         $typeInst = Code\Helpers::createObject($className, array());
         /** @var Doctrine\DBAL\Types\Type $typeInst */
         $dbalTypes[$typeInst->getName()] = $className;
         $schemaTypes[$dbType] = $typeInst->getName();
     }
     // connection
     $options = array_diff_key($config, array_flip(array('types', 'resultCache', 'connection', 'logging')));
     $connection = $builder->addDefinition($connectionServiceId = $this->prefix($name . '.connection'))->setClass('Kdyby\\Doctrine\\Connection')->setFactory('Kdyby\\Doctrine\\Connection::create', array($options, $this->prefix('@' . $name . '.dbalConfiguration'), $this->prefix('@' . $name . '.evm')))->addSetup('setSchemaTypes', array($schemaTypes))->addSetup('setDbalTypes', array($dbalTypes))->addTag(self::TAG_CONNECTION)->setAutowired($isDefault)->setInject(FALSE);
     /** @var Nette\DI\ServiceDefinition $connection */
     $this->configuredConnections[$name] = $connectionServiceId;
     if (!is_bool($config['logging'])) {
         $fileLogger = new Statement('Kdyby\\Doctrine\\Diagnostics\\FileLogger', array($builder->expand($config['logging'])));
         $configuration->addSetup('$service->getSQLLogger()->addLogger(?)', array($fileLogger));
     } elseif ($config['logging']) {
         $connection->addSetup('Kdyby\\Doctrine\\Diagnostics\\Panel::register', array('@self'));
     }
     return $this->prefix('@' . $name . '.connection');
 }
开发者ID:peterkrejci,项目名称:music-collection,代码行数:34,代码来源:OrmExtension.php


示例14: formatPhp

 /**
  * Formats PHP statement.
  * @return string
  * @internal
  */
 public function formatPhp($statement, $args)
 {
     array_walk_recursive($args, function (&$val) {
         if ($val instanceof Statement) {
             $val = new PhpLiteral($this->formatStatement($val));
         } elseif (is_string($val) && substr($val, 0, 2) === '@@') {
             // escaped text @@
             $val = substr($val, 1);
         } elseif (is_string($val) && substr($val, 0, 1) === '@' && strlen($val) > 1) {
             // service reference
             $name = substr($val, 1);
             if ($name === ContainerBuilder::THIS_CONTAINER) {
                 $val = new PhpLiteral('$this');
             } elseif ($name === $this->currentService) {
                 $val = new PhpLiteral('$service');
             } else {
                 $val = new PhpLiteral($this->formatStatement(new Statement(['@' . ContainerBuilder::THIS_CONTAINER, 'getService'], [$name])));
             }
         }
     });
     return PhpHelpers::formatArgs($statement, $args);
 }
开发者ID:nette,项目名称:di,代码行数:27,代码来源:PhpGenerator.php


示例15: doSerializeValueResolve

 private function doSerializeValueResolve(ContainerBuilder $builder, $expression)
 {
     if ($expression instanceof Code\PhpLiteral) {
         $expression = self::resolveExpression($expression);
     } elseif (substr($expression, 0, 1) === '%') {
         $expression = $builder->expand($expression);
     } elseif (substr($expression, 0, 1) === '$') {
         $expression = new Code\PhpLiteral($expression);
     } else {
         if (!($m = self::shiftAccessPath($expression))) {
             return $expression;
             // it's probably some kind of expression
         } else {
             if ($m['context'] === 'this') {
                 $targetObject = '$this';
             } elseif ($m['context'] === 'context' && ($p = self::shiftAccessPath($m['path']))) {
                 if (class_exists($p['context']) || interface_exists($p['context'])) {
                     $targetObject = Code\Helpers::format('$this->_kdyby_aopContainer->getByType(?)', $p['context']);
                 } else {
                     $targetObject = Code\Helpers::format('$this->_kdyby_aopContainer->getService(?)', $p['context']);
                 }
                 $m['path'] = $p['path'];
             } else {
                 throw new Kdyby\Aop\NotImplementedException();
             }
             $expression = Code\Helpers::format('PropertyAccess::createPropertyAccessor()->getValue(?, ?)', new Code\PhpLiteral($targetObject), $m['path']);
         }
         $expression = new Code\PhpLiteral($expression);
     }
     return $expression;
 }
开发者ID:kdyby,项目名称:aop,代码行数:31,代码来源:Criteria.php


示例16: formatPhp

 /**
  * Formats PHP statement.
  * @return string
  */
 public function formatPhp($statement, $args)
 {
     $that = $this;
     array_walk_recursive($args, function (&$val) use($that) {
         if ($val instanceof Statement) {
             $val = ContainerBuilder::literal($that->formatStatement($val));
         } elseif ($val === $that) {
             $val = ContainerBuilder::literal('$this');
         } elseif ($val instanceof ServiceDefinition) {
             $val = '@' . current(array_keys($that->definitions, $val, TRUE));
         } elseif (is_string($val) && preg_match('#^[\\w\\\\]*::[A-Z][A-Z0-9_]*\\z#', $val, $m)) {
             $val = ContainerBuilder::literal(ltrim($val, ':'));
         }
         if (is_string($val) && substr($val, 0, 1) === '@') {
             $pair = explode('::', $val, 2);
             $name = $that->getServiceName($pair[0]);
             if (isset($pair[1]) && preg_match('#^[A-Z][A-Z0-9_]*\\z#', $pair[1], $m)) {
                 $val = $that->definitions[$name]->class . '::' . $pair[1];
             } else {
                 if ($name === ContainerBuilder::THIS_CONTAINER) {
                     $val = '$this';
                 } elseif ($name === $that->currentService) {
                     $val = '$service';
                 } else {
                     $val = $that->formatStatement(new Statement(array('@' . ContainerBuilder::THIS_CONTAINER, 'getService'), array($name)));
                 }
                 $val .= isset($pair[1]) ? PhpHelpers::formatArgs('->?', array($pair[1])) : '';
             }
             $val = ContainerBuilder::literal($val);
         }
     });
     return PhpHelpers::formatArgs($statement, $args);
 }
开发者ID:rostenkowski,项目名称:nette,代码行数:37,代码来源:ContainerBuilder.php


示例17: dump

 /**
  * Generates configuration in PHP format.
  * @return string
  */
 public function dump(array $data)
 {
     return "<?php // generated by Nette \nreturn " . Nette\PhpGenerator\Helpers::dump($data) . ';';
 }
开发者ID:jurasm2,项目名称:nette,代码行数:8,代码来源:PhpAdapter.php


示例18: compilePhpCache

    /**
     * @param Translator $translator
     * @param MessageCatalogueInterface[] $availableCatalogues
     * @param string $locale
     * @return string
     */
    protected function compilePhpCache(Translator $translator, array &$availableCatalogues, $locale)
    {
        $fallbackContent = '';
        $current = new Code\PhpLiteral('');
        foreach ($this->fallbackResolver->compute($translator, $locale) as $fallback) {
            $fallbackSuffix = new Code\PhpLiteral(ucfirst(preg_replace('~[^a-z0-9_]~i', '_', $fallback)));
            $fallbackContent .= Code\Helpers::format(<<<EOF
\$catalogue? = new MessageCatalogue(?, ?);
\$catalogue?->addFallbackCatalogue(\$catalogue?);

EOF
, $fallbackSuffix, $fallback, $availableCatalogues[$fallback]->all(), $current, $fallbackSuffix);
            $current = $fallbackSuffix;
        }
        $content = Code\Helpers::format(<<<EOF
use Kdyby\\Translation\\MessageCatalogue;

\$catalogue = new MessageCatalogue(?, ?);

?
return \$catalogue;

EOF
, $locale, $availableCatalogues[$locale]->all(), new Code\PhpLiteral($fallbackContent));
        return '<?php' . "\n\n" . $content;
    }
开发者ID:tomasstrejcek,项目名称:Translation,代码行数:32,代码来源:CatalogueCompiler.php


示例19: __toString

 /** @return string  PHP code */
 public function __toString()
 {
     $parameters = array();
     foreach ($this->parameters as $param) {
         $parameters[] = ($param->typeHint ? $param->typeHint . ' ' : '') . ($param->reference ? '&' : '') . '$' . $param->name . ($param->optional ? ' = ' . Helpers::dump($param->defaultValue) : '');
     }
     $uses = array();
     foreach ($this->uses as $param) {
         $uses[] = ($param->reference ? '&' : '') . '$' . $param->name;
     }
     return ($this->documents ? str_replace("\n", "\n * ", "/**\n" . implode("\n", (array) $this->documents)) . "\n */\n" : '') . ($this->abstract ? 'abstract ' : '') . ($this->final ? 'final ' : '') . ($this->visibility ? $this->visibility . ' ' : '') . ($this->static ? 'static ' : '') . 'function' . ($this->returnReference ? ' &' : '') . ($this->name ? ' ' . $this->name : '') . '(' . implode(', ', $parameters) . ')' . ($this->uses ? ' use (' . implode(', ', $uses) . ')' : '') . ($this->abstract || $this->body === FALSE ? ';' : ($this->name ? "\n" : ' ') . "{\n" . Nette\Utils\Strings::indent(trim($this->body), 1) . "\n}");
 }
开发者ID:jurasm2,项目名称:nette,代码行数:13,代码来源:Method.php


示例20: afterCompile

 public function afterCompile(Code\ClassType $class)
 {
     $init = $class->methods['initialize'];
     /** @hack This tries to add the event invokation right after the code, generated by NetteExtension. */
     $foundNetteInitStart = $foundNetteInitEnd = FALSE;
     $lines = explode(";\n", trim($init->body));
     $init->body = NULL;
     while (($line = array_shift($lines)) || $lines) {
         if ($foundNetteInitStart && !$foundNetteInitEnd && stripos($line, 'Nette\\') === FALSE && stripos($line, 'set_include_path') === FALSE && stripos($line, 'date_default_timezone_set') === FALSE) {
             $init->addBody(Code\Helpers::format('$this->getService(?)->createEvent(?)->dispatch($this);', $this->prefix('manager'), array('Nette\\DI\\Container', 'onInitialize')));
             $foundNetteInitEnd = TRUE;
         }
         if (!$foundNetteInitEnd && (stripos($line, 'Nette\\') !== FALSE || stripos($line, 'set_include_path') !== FALSE || stripos($line, 'date_default_timezone_set') !== FALSE)) {
             $foundNetteInitStart = TRUE;
         }
         $init->addBody($line . ';');
     }
     if (!$foundNetteInitEnd) {
         $init->addBody(Code\Helpers::format('$this->getService(?)->createEvent(?)->dispatch($this);', $this->prefix('manager'), array('Nette\\DI\\Container', 'onInitialize')));
     }
 }
开发者ID:hranicka,项目名称:kdyby-events,代码行数:21,代码来源:EventsExtension.php



注:本文中的Nette\PhpGenerator\Helpers类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Reflection\AnnotationsParser类代码示例发布时间:2022-05-23
下一篇:
PHP PhpGenerator\ClassType类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap