本文整理汇总了PHP中Symfony\Component\DependencyInjection\Container::compile方法的典型用法代码示例。如果您正苦于以下问题:PHP Container::compile方法的具体用法?PHP Container::compile怎么用?PHP Container::compile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\DependencyInjection\Container
的用法示例。
在下文中一共展示了Container::compile方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testIsFrozen
public function testIsFrozen()
{
$sc = new Container(new ParameterBag(array('foo' => 'bar')));
$this->assertFalse($sc->isFrozen(), '->isFrozen() returns false if the parameters are not frozen');
$sc->compile();
$this->assertTrue($sc->isFrozen(), '->isFrozen() returns true if the parameters are frozen');
}
示例2: getDumpedContainer
private function getDumpedContainer()
{
static $i = 0;
$class = 'WebProfilerExtensionTestContainer' . $i++;
$this->container->compile();
$dumper = new PhpDumper($this->container);
eval('?>' . $dumper->dump(array('class' => $class)));
$container = new $class();
$container->set('kernel', $this->kernel);
return $container;
}
示例3: getContainer
/**
* Returns ContainerBuilder by including the default file 'containerBuilder.php' from settings directory.
*
* @throws \RuntimeException
*/
protected function getContainer()
{
if ($this->innerContainer instanceof ContainerInterface) {
// Do nothing
} elseif (!is_readable($this->innerContainer)) {
throw new RuntimeException(sprintf("Unable to read file %s\n", $this->innerContainer));
} else {
// 'containerBuilder.php' file expects $installDir variable to be set by caller
$installDir = $this->installDir;
$this->innerContainer = (require_once $this->innerContainer);
}
// Compile container if necessary
if ($this->innerContainer instanceof ContainerBuilder && !$this->innerContainer->isFrozen()) {
$this->innerContainer->compile();
}
}
示例4: compile
/**
* Compiles the container.
*
* This method passes the container to compiler
* passes whose job is to manipulate and optimize
* the container.
*
* The main compiler passes roughly do four things:
*
* * The extension configurations are merged;
* * Parameter values are resolved;
* * The parameter bag is frozen;
* * Extension loading is disabled.
*/
public function compile()
{
$compiler = $this->getCompiler();
if ($this->trackResources) {
foreach ($compiler->getPassConfig()->getPasses() as $pass) {
$this->addObjectResource($pass);
}
}
$compiler->compile($this);
if ($this->trackResources) {
foreach ($this->definitions as $definition) {
if ($definition->isLazy() && ($class = $definition->getClass()) && class_exists($class)) {
$this->addClassResource(new \ReflectionClass($class));
}
}
}
$this->extensionConfigs = array();
parent::compile();
}
示例5: compile
/**
* Compiles the container.
*
* This method passes the container to compiler
* passes whose job is to manipulate and optimize
* the container.
*
* The main compiler passes roughly do four things:
*
* * The extension configurations are merged;
* * Parameter values are resolved;
* * The parameter bag is frozen;
* * Extension loading is disabled.
*
* @api
*/
public function compile()
{
if (null === $this->compiler) {
$this->compiler = new Compiler();
}
foreach ($this->compiler->getPassConfig()->getPasses() as $pass) {
$this->addObjectResource($pass);
}
$this->compiler->compile($this);
$this->extensionConfigs = array();
parent::compile();
}
示例6: compile
/**
* Compiles the container.
*
* This method passes the container to compiler
* passes whose job is to manipulate and optimize
* the container.
*
* The main compiler passes roughly do four things:
*
* * The extension configurations are merged;
* * Parameter values are resolved;
* * The parameter bag is frozen;
* * Extension loading is disabled.
*/
public function compile()
{
$this->compiler->compile($this);
$this->setExtensionConfigs(array());
parent::compile();
}
示例7: compile
/**
* Compiles the container.
*
* This method passes the container to compiler
* passes whose job is to manipulate and optimize
* the container.
*
* The main compiler passes roughly do four things:
*
* * The extension configurations are merged;
* * Parameter values are resolved;
* * The parameter bag is frozen;
* * Extension loading is disabled.
*/
public function compile()
{
$compiler = $this->getCompiler();
if ($this->trackResources) {
foreach ($compiler->getPassConfig()->getPasses() as $pass) {
$this->addObjectResource($pass);
}
}
$compiler->compile($this);
$this->compiled = true;
foreach ($this->definitions as $id => $definition) {
if (!$definition->isPublic()) {
$this->privates[$id] = true;
}
if ($this->trackResources && $definition->isLazy() && ($class = $definition->getClass()) && class_exists($class)) {
$this->addClassResource(new \ReflectionClass($class));
}
}
$this->extensionConfigs = array();
$bag = $this->getParameterBag();
parent::compile();
$this->envPlaceholders = $bag instanceof EnvPlaceholderParameterBag ? $bag->getEnvPlaceholders() : array();
}
示例8: createTranslator
protected function createTranslator($em, $cacheDir)
{
$listener = new GetDatabaseResourcesListener($this->getORMStorage($em), 'xxxxx');
$dispatcher = new EventDispatcher();
$dispatcher->addListener('lexik_translation.event.get_database_resources', array($listener, 'onGetDatabaseResources'));
$container = new Container();
$container->set('event_dispatcher', $dispatcher);
$container->compile();
$loaderIds = array();
$options = array('cache_dir' => $cacheDir);
return new TranslatorMock($container, new MessageSelector(), $loaderIds, $options);
}
示例9: compile
/**
* Compiles the container.
*
* This method passes the container to compiler
* passes whose job is to manipulate and optimize
* the container.
*
* The main compiler passes roughly do four things:
*
* * The extension configurations are merged;
* * Parameter values are resolved;
* * The parameter bag is frozen;
* * Extension loading is disabled.
*/
public function compile()
{
if (null === $this->compiler) {
$this->initializeCompiler();
}
$this->compiler->compile($this);
$this->setExtensionConfigs(array());
parent::compile();
}
示例10: dumpContainer
/**
* Dump a container
* @param Container $container
* @param $class
* @param $location
* @param string $baseClass
* @throws \RuntimeException
*/
public static function dumpContainer(Container $container, $class, $location, $baseClass = 'Symfony\\Component\\DependencyInjection\\Container')
{
if (!file_exists($location)) {
throw new RuntimeException('Dump location does not exist');
}
$container->compile();
$dumper = new PhpDumper($container);
file_put_contents(realpath($location) . "/{$class}.php", $dumper->dump(array('class' => $class, 'base_class' => $baseClass)));
}