本文整理汇总了PHP中Drupal\Core\DependencyInjection\ContainerBuilder::compile方法的典型用法代码示例。如果您正苦于以下问题:PHP ContainerBuilder::compile方法的具体用法?PHP ContainerBuilder::compile怎么用?PHP ContainerBuilder::compile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Drupal\Core\DependencyInjection\ContainerBuilder
的用法示例。
在下文中一共展示了ContainerBuilder::compile方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testSetOnSynchronizedService
/**
* Tests set with a synchronized service.
*/
public function testSetOnSynchronizedService()
{
$container = new ContainerBuilder();
$container->register('baz', 'BazClass')->setSynchronized(TRUE);
$container->register('bar', 'BarClass')->addMethodCall('setBaz', array(new Reference('baz')));
// Ensure that we can set services on a compiled container.
$container->compile();
$container->set('baz', $baz = new \BazClass());
$this->assertSame($baz, $container->get('bar')->getBaz());
$container->set('baz', $baz = new \BazClass());
$this->assertSame($baz, $container->get('bar')->getBaz());
}
示例2: runApp
namespace Acquia\D8\Workshop;
use Drupal\Core\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Definition;
use Symfony\Component\DependencyInjection\Reference;
use Symfony\Component\Stopwatch\Stopwatch;
use Symfony\Component\VarDumper\VarDumper;
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\Dumper\PhpDumper;
require __DIR__ . '../../../vendor/autoload.php';
$container = new ContainerBuilder();
$loader = new YamlFileLoader($container, new FileLocator(__DIR__ . '/config'));
$loader->load('services.yml');
$container->get('stopwatch')->start('Build container');
$container->compile();
$dump = new PhpDumper($container);
file_put_contents(__DIR__ . '/cached_container.php', $dump->dump());
$build = $container->get('stopwatch')->stop('Build container');
dump($build->getDuration() . "ms");
//runApp($container);
function runApp(ContainerBuilder $container)
{
$container->get('stopwatch')->start('Acquia D8 Workshop');
// Calculate.
// Calculate something.
$factorial = 1;
for ($x = 100; $x >= 1; $x--) {
$factorial = $factorial * $x;
}
dump($factorial);