本文整理匯總了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);
}
示例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);
}
示例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())];
}