本文整理汇总了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())];
}