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


PHP HttpKernelInterface::getContainer方法代碼示例

本文整理匯總了PHP中Symfony\Component\HttpKernel\HttpKernelInterface::getContainer方法的典型用法代碼示例。如果您正苦於以下問題:PHP HttpKernelInterface::getContainer方法的具體用法?PHP HttpKernelInterface::getContainer怎麽用?PHP HttpKernelInterface::getContainer使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Symfony\Component\HttpKernel\HttpKernelInterface的用法示例。


在下文中一共展示了HttpKernelInterface::getContainer方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: createClient

 /**
  * Creates a Client.
  *
  * @param array $options An array of options to pass to the createKernel class
  * @param array $server  An array of server parameters
  * @param array $cookies An array of Symfony\Component\BrowserKit\Cookie
  *
  * @return Client A Client instance
  */
 public function createClient(array $options = array(), array $server = array(), array $cookies = array())
 {
     if (null !== $this->kernel && $this->kernelReset) {
         $this->kernel->shutdown();
         $this->kernel->boot();
     }
     if (null === $this->kernel) {
         $this->kernel = $this->createKernel($options);
         $this->kernel->boot();
     }
     $client = $this->kernel->getContainer()->get('test.client');
     $client->setServerParameters($server);
     foreach ($cookies as $cookie) {
         $client->getCookieJar()->set($cookie);
     }
     return $client;
 }
開發者ID:SelviA,項目名稱:AtoumBundle,代碼行數:26,代碼來源:WebTestCase.php

示例2: defineCurrency

 protected function defineCurrency(Request $request)
 {
     $currency = null;
     if ($request->query->has("currency")) {
         $currency = CurrencyQuery::create()->findOneByCode($request->query->get("currency"));
         if ($currency) {
             if (false === $this->app->getContainer()->isScopeActive('request')) {
                 $this->app->getContainer()->enterScope('request');
                 $this->app->getContainer()->set('request', $request, 'request');
             }
             $this->eventDispatcher->dispatch(TheliaEvents::CHANGE_DEFAULT_CURRENCY, new CurrencyChangeEvent($currency, $request));
         }
     } else {
         $currency = $request->getSession()->getCurrency(false);
     }
     if (null === $currency) {
         $currency = Currency::getDefaultCurrency();
     }
     return $currency;
 }
開發者ID:NandoKstroNet,項目名稱:thelia,代碼行數:20,代碼來源:ParamInitMiddleware.php

示例3: getContainer

 /**
  * @return mixed
  */
 public function getContainer()
 {
     return static::$kernel->getContainer();
 }
開發者ID:WeavingTheWeb,項目名稱:FrameworkExtraBundle,代碼行數:7,代碼來源:TestCase.php


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