當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Compiler::compile方法代碼示例

本文整理匯總了PHP中Nette\DI\Compiler::compile方法的典型用法代碼示例。如果您正苦於以下問題:PHP Compiler::compile方法的具體用法?PHP Compiler::compile怎麽用?PHP Compiler::compile使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Nette\DI\Compiler的用法示例。


在下文中一共展示了Compiler::compile方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: fixCompile

 /**
  * @param \Nette\DI\Compiler $compiler
  * @return string
  */
 protected function fixCompile(\Nette\DI\Compiler $compiler)
 {
     $code = $this->compiler->compile();
     if (!is_array($code)) {
         return $code;
     }
     return implode("\n\n\n", $code);
 }
開發者ID:webchemistry,項目名稱:forms-multiplier,代碼行數:12,代碼來源:ExtensionTest.php

示例2: compile

 protected function compile()
 {
     $result = $this->compiler->compile();
     if (is_array($result)) {
         return implode("\n\n\n", $result);
     }
     return $result;
 }
開發者ID:webchemistry,項目名稱:forms-controls,代碼行數:8,代碼來源:ExtensionTest.php

示例3: testGettingImageStorage

 public function testGettingImageStorage()
 {
     eval($this->compiler->compile());
     /** @var \Nette\DI\Container $container */
     $container = new Container();
     $this->assertNotNull($class = $container->getByType(\WebChemistry\Images\IImageStorage::class));
     $this->assertInstanceOf(\WebChemistry\Images\IImageStorage::class, $class);
     $this->assertInstanceOf(\WebChemistry\Images\AbstractStorage::class, $class);
 }
開發者ID:webchemistry,項目名稱:images,代碼行數:9,代碼來源:ExtensionTest.php

示例4: testEvents

 public function testEvents()
 {
     $this->compiler->setClassName('Container_Events');
     eval($this->compiler->compile());
     /** @var \Nette\DI\Container $container */
     $container = new Container_Events();
     /** @var _MockStorage $class */
     $this->assertNotNull($class = $container->getByType(\WebChemistry\Images\IImageStorage::class));
     $this->assertInstanceOf(\WebChemistry\Images\IImageStorage::class, $class);
     $this->assertInstanceOf(_MockStorage::class, $class);
     $events = $class->getEvents()['onCreate'];
     $this->assertTrue(is_callable($events[0]));
     $events[0]();
     $this->assertTrue(_Events::$called);
     _Events::$called = FALSE;
     $this->assertTrue(is_callable($events[1]));
     $events[1]();
     $this->assertTrue(_Events::$called);
 }
開發者ID:webchemistry,項目名稱:images,代碼行數:19,代碼來源:EventsTest.php

示例5: generate

 /**
  * @return array of (code, file[])
  */
 protected function generate($class, $generator)
 {
     $compiler = new Compiler();
     $compiler->getContainerBuilder()->setClassName($class);
     $code = call_user_func_array($generator, [&$compiler]);
     $code = $code ?: implode("\n\n\n", $compiler->compile());
     $files = $compiler->getDependencies();
     $files = call_user_func($this->filter, $files);
     $files = array_combine($files, $files);
     return array("<?php\n{$code}", serialize(@array_map('filemtime', $files)));
 }
開發者ID:arachne,項目名稱:bootstrap,代碼行數:14,代碼來源:ContainerLoader.php

示例6: generate

 /**
  * @return array of (code, file[])
  */
 protected function generate($class, $generator)
 {
     $compiler = new Compiler();
     $compiler->getContainerBuilder()->setClassName($class);
     $code = call_user_func_array($generator, array(&$compiler));
     $code = $code ?: implode("\n\n\n", $compiler->compile());
     $files = $compiler->getDependencies();
     $files = $files ? array_combine($files, $files) : array();
     // workaround for PHP 5.3 array_combine
     return array("<?php\n{$code}", serialize(@array_map('filemtime', $files)));
 }
開發者ID:knedle,項目名稱:twitter-nette-skeleton,代碼行數:14,代碼來源:ContainerLoader.php

示例7: generateContainer

 /**
  * @param Compiler $compiler
  * @return string
  */
 public function generateContainer(Compiler $compiler)
 {
     // Load configs
     $loader = new Loader();
     $compiler->addConfig(['parameters' => $this->parameters]);
     foreach ($this->configs as $config) {
         $compiler->addConfig($loader->load($config));
     }
     $compiler->addDependencies($loader->getDependencies());
     // Exclude classes
     $builder = $compiler->getContainerBuilder();
     $builder->addExcludedClasses($this->excludedClasses);
     // Fire events
     foreach ($this->onCompile as $cb) {
         call_user_func_array($cb, [$compiler]);
     }
     // Compile container
     $classes = $compiler->compile();
     $classes[0]->setExtends(PiDiContainer::class);
     return implode("\n", []) . "\n\n" . implode("\n\n\n", $classes);
 }
開發者ID:phalette,項目名稱:pidic,代碼行數:25,代碼來源:Configurator.php

示例8: testCompile

 public function testCompile()
 {
     $this->compiler->compile();
 }
開發者ID:webchemistry,項目名稱:parameters,代碼行數:4,代碼來源:ExtensionTest.php

示例9: generate

 /**
  * @return array of (code, file[])
  */
 protected function generate($class, $generator)
 {
     $compiler = new Compiler();
     $compiler->setClassName($class);
     $code = call_user_func_array($generator, [&$compiler]) ?: $compiler->compile();
     return ["<?php\n{$code}", serialize($compiler->exportDependencies())];
 }
開發者ID:nette,項目名稱:di,代碼行數:10,代碼來源:ContainerLoader.php


注:本文中的Nette\DI\Compiler::compile方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。