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


PHP Compiler::setClassName方法代碼示例

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


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

示例1: testOptions

 public function testOptions()
 {
     $this->compiler->setClassName('Container_Controls');
     $this->compiler->addConfig(['controls' => ['date' => ['format' => 'foo'], 'translations' => ['enable' => TRUE, 'date' => 'bar']]]);
     $this->compile();
     eval($this->compile());
     $container = new Container_Controls();
     $count = count(\Nette\Forms\Validator::$messages);
     $container->initialize();
     $this->assertNotSame($count, count(\Nette\Forms\Validator::$messages));
     $this->assertSame('bar', \Nette\Forms\Validator::$messages[\WebChemistry\Forms\Controls\Date::VALID]);
     $this->assertSame('foo', \WebChemistry\Forms\Controls\Date::$dateFormat);
 }
開發者ID:webchemistry,項目名稱:forms-controls,代碼行數:13,代碼來源:ExtensionTest.php

示例2: 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

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