本文整理汇总了PHP中AppKernel::getContainer方法的典型用法代码示例。如果您正苦于以下问题:PHP AppKernel::getContainer方法的具体用法?PHP AppKernel::getContainer怎么用?PHP AppKernel::getContainer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AppKernel
的用法示例。
在下文中一共展示了AppKernel::getContainer方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setUp
public function setUp()
{
$this->kernel = new \AppKernel('test', true);
$this->kernel->boot();
$this->container = $this->kernel->getContainer();
parent::setUp();
}
示例2: loadSf2
private function loadSf2()
{
global $kernel;
//@settings_fields('wp_symfony_settings');
//@do_settings_fields('wp_symfony_settings');
$path = get_option('symfony2_path');
$env = get_option('symfony2_env');
$url = get_option('symfony2_url');
if (!$this->isValidSymfonyPath($path)) {
add_action('admin_footer', array($this, 'symfony2_warning'));
return;
}
if ($kernel == null) {
$loader = (require_once $path . 'app/bootstrap.php.cache');
require_once $path . 'app/AppKernel.php';
$kernel = new AppKernel($env, true);
$kernel->loadClassCache();
$kernel->boot();
$this->kernel = $kernel;
$this->container = $kernel->getContainer();
if ($this->container->get('session')->isStarted() == false) {
$this->container->get('session')->start();
}
if ($url != null) {
$this->overloadUrlContext($url);
}
} else {
$this->kernel = $kernel;
$this->container = $kernel->getContainer();
}
$wp_loader = $this->container->get('wordpress.loader');
$wp_loader->load();
}
示例3: setUp
protected function setUp()
{
$kernel = new \AppKernel('test', false);
$kernel->boot();
$this->articleRepository = $kernel->getContainer()->get('app.article_repository');
$this->queryBus = $kernel->getContainer()->get('gnugat_query_bus.query_bus');
}
示例4: __construct
public function __construct(PHP_CodeCoverage_Driver $driver = NULL, PHP_CodeCoverage_Filter $filter = NULL)
{
require $_SERVER['KERNEL_DIR'] . '/AppKernel.php';
$this->appKernel = new \AppKernel('test', true);
$this->appKernel->boot();
$this->twig = $this->appKernel->getContainer()->get('twig');
$this->twigCacheRegex = '#^' . $this->twig->getCache() . '/././([0-9a-f]+)\\.php$#';
$filter->addDirectoryToWhitelist($this->twig->getCache());
parent::__construct($driver, $filter);
}
示例5: __construct
/**
* Construct a test case.
*/
public function __construct()
{
parent::__construct();
self::$kernel = new \AppKernel('test', true);
self::$kernel->boot();
self::$application = new Application(self::$kernel);
self::$application->setAutoExit(false);
self::$container = self::$kernel->getContainer();
self::$doctrine = $this->get('doctrine');
}
示例6: testCacheCompilerPass
public function testCacheCompilerPass()
{
static::assertTrue(self::$kernel->getContainer()->has('s.teavee_object_cache.registrar'));
$registrar = self::$kernel->getContainer()->get('s.teavee_object_cache.registrar');
static::assertInstanceOf('Scribe\\Teavee\\ObjectCacheBundle\\DependencyInjection\\Compiler\\Registrar\\CacheCompilerRegistrar', $registrar);
static::assertCount(3, $registrar->getAttendantCollection());
static::assertTrue(self::$kernel->getContainer()->has('s.teavee_object_cache.key_generator'));
$g = self::$kernel->getContainer()->get('s.teavee_object_cache.key_generator');
foreach ($registrar->getAttendantCollection() as $attendant) {
static::assertEquals($g, $attendant->getKeyGenerator());
}
}
示例7: _initialize
public function _initialize()
{
/** @var CodeceptionModule\Symfony2 $module */
$module = $this->getModule('Symfony2');
/** @var \AppKernel $kernel */
$this->kernel = $module->kernel;
$this->container = $this->kernel->getContainer();
$this->entityManager = $this->container->get('doctrine.orm.entity_manager');
$this->fixturesFinder = $this->container->get('hautelook_alice.doctrine.orm.fixtures_finder');
$this->fixturesLoader = $this->container->get('hautelook_alice.fixtures.loader');
$this->fixturesExecutor = $this->container->get('hautelook_alice.doctrine.executor.fixtures_executor');
$this->bundleResolver = $this->container->get('hautelook_alice.bundle_resolver');
$this->schemaTool = new SchemaTool($this->entityManager);
}
示例8: setServiceKernel
/**
* 每个testXXX执行之前,都会执行此函数,净化数据库。
*
* NOTE: 如果数据库已创建,那么执行清表操作,不重建。
*/
private function setServiceKernel()
{
$kernel = new \AppKernel('test', false);
$kernel->loadClassCache();
$kernel->boot();
Request::enableHttpMethodParameterOverride();
$request = Request::createFromGlobals();
$serviceKernel = ServiceKernel::create($kernel->getEnvironment(), $kernel->isDebug());
$serviceKernel->setParameterBag($kernel->getContainer()->getParameterBag());
$serviceKernel->setConnection($kernel->getContainer()->get('database_connection'));
$currentUser = new CurrentUser();
$currentUser->fromArray(array('id' => 1, 'nickname' => 'admin', 'email' => 'admin@admin.com', 'password' => 'admin', 'currentIp' => '127.0.0.1', 'roles' => array('ROLE_USER', 'ROLE_ADMIN', 'ROLE_SUPER_ADMIN', 'ROLE_TEACHER')));
$serviceKernel->setCurrentUser($currentUser);
$this->serviceKernel = $serviceKernel;
}
示例9: __construct
public function __construct()
{
$kernel = new \AppKernel("test", true);
$kernel->boot();
$this->_container = $kernel->getContainer();
$this->searchEngine = $this->get('beecms.search.service');
}
示例10: setUp
protected function setUp()
{
$kernel = new \AppKernel('test', true);
$kernel->boot();
$this->container = $kernel->getContainer();
$this->youtube = $this->container->get('awy.google.youtube');
}
示例11: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
$environments = explode(',', $input->getArgument('environments'));
$table = (new Table($output))->setHeaders(['env', 'key', 'value']);
foreach ($environments as $key => $environment) {
if ($key > 0) {
$table->addRow(new TableSeparator());
}
$environmentKernel = new \AppKernel($environment, false);
$environmentKernel->initializeWithoutCaching();
foreach ($environmentKernel->getContainer()->getParameterBag()->all() as $parameter => $value) {
if ($input->getOption('filter') !== null) {
$pattern = sprintf('~%s~', $input->getOption('filter'));
if (!preg_match($pattern, $parameter)) {
continue;
}
}
if (is_array($value)) {
$value = json_encode($value);
}
$table->addRow([$environment, $parameter, $value]);
}
}
$table->render();
}
示例12: __construct
public function __construct()
{
$kernel = new AppKernel('test', true);
$kernel->boot();
$this->em = $kernel->getContainer()->get('doctrine.orm.entity_manager');
$this->kernel = $kernel;
}
示例13: __construct
public function __construct()
{
$kernel = new \AppKernel("test", true);
$kernel->boot();
$this->container = $kernel->getContainer();
parent::__construct();
}
示例14: setUp
public function setUp()
{
$kernel = new \AppKernel('test', true);
$kernel->boot();
$this->container = $kernel->getContainer();
$this->service = $this->container->get('dugun_upload.service.upload_service');
}
示例15: setUpBeforeClass
public static function setUpBeforeClass()
{
require_once "{$_SERVER['KERNEL_DIR']}/AppKernel.php";
$kernel = new \AppKernel('test', true);
$kernel->boot();
self::$validator = $kernel->getContainer()->get('validator');
}