當前位置: 首頁>>代碼示例>>PHP>>正文


PHP AppKernel::getContainer方法代碼示例

本文整理匯總了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();
 }
開發者ID:Codixis,項目名稱:CSBill,代碼行數:7,代碼來源:KernelAwareTest.php

示例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();
 }
開發者ID:cmoncy,項目名稱:WordpressBundle,代碼行數:33,代碼來源:sf2plugin.php

示例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');
 }
開發者ID:gnugat,項目名稱:query-bus-bundle,代碼行數:7,代碼來源:ServiceTest.php

示例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);
 }
開發者ID:Trismegiste,項目名稱:thatch,代碼行數:10,代碼來源:CodeCoverage.php

示例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');
 }
開發者ID:ubermichael,項目名稱:symftest,代碼行數:13,代碼來源:FixturesTestCase.php

示例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());
     }
 }
開發者ID:scr-be,項目名稱:teavee-object-cache-bundle,代碼行數:12,代碼來源:ScribeTeaveeObjectCacheBundleTest.php

示例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);
 }
開發者ID:alsbury,項目名稱:malice,代碼行數:14,代碼來源:Malice.php

示例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;
 }
開發者ID:styling,項目名稱:LeesPharm,代碼行數:20,代碼來源:BaseTestCase.php

示例9: __construct

 public function __construct()
 {
     $kernel = new \AppKernel("test", true);
     $kernel->boot();
     $this->_container = $kernel->getContainer();
     $this->searchEngine = $this->get('beecms.search.service');
 }
開發者ID:beecms,項目名稱:search-bundle,代碼行數:7,代碼來源:SearchEngineTest.php

示例10: setUp

 protected function setUp()
 {
     $kernel = new \AppKernel('test', true);
     $kernel->boot();
     $this->container = $kernel->getContainer();
     $this->youtube = $this->container->get('awy.google.youtube');
 }
開發者ID:andywooyay,項目名稱:AwyGoogleApiBundle,代碼行數:7,代碼來源:YoutubeTest.php

示例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();
 }
開發者ID:kmelia,項目名稱:fresh-symfony,代碼行數:25,代碼來源:ParametersCommand.php

示例12: __construct

 public function __construct()
 {
     $kernel = new AppKernel('test', true);
     $kernel->boot();
     $this->em = $kernel->getContainer()->get('doctrine.orm.entity_manager');
     $this->kernel = $kernel;
 }
開發者ID:heristop,項目名稱:HeriWebServiceBundle,代碼行數:7,代碼來源:ClientTest.php

示例13: __construct

 public function __construct()
 {
     $kernel = new \AppKernel("test", true);
     $kernel->boot();
     $this->container = $kernel->getContainer();
     parent::__construct();
 }
開發者ID:vladislavs1321,項目名稱:demo,代碼行數:7,代碼來源:SearchServiceTest.php

示例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');
 }
開發者ID:duguncom,項目名稱:DugunUploadBundle,代碼行數:7,代碼來源:DownloadTest.php

示例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');
 }
開發者ID:kadala,項目名稱:AcmePizzaBundle,代碼行數:7,代碼來源:AbstractEntityTest.php


注:本文中的AppKernel::getContainer方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。