当前位置: 首页>>代码示例>>PHP>>正文


PHP KernelInterface::getContainer方法代码示例

本文整理汇总了PHP中Symfony\Component\HttpKernel\KernelInterface::getContainer方法的典型用法代码示例。如果您正苦于以下问题:PHP KernelInterface::getContainer方法的具体用法?PHP KernelInterface::getContainer怎么用?PHP KernelInterface::getContainer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Symfony\Component\HttpKernel\KernelInterface的用法示例。


在下文中一共展示了KernelInterface::getContainer方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getUrlFromPath

 /**
  * Generates a url from a given patch
  *
  * @param $path
  * @param $method
  * @return string
  */
 protected function getUrlFromPath($path, $method = 'GET')
 {
     try {
         $baseUrl = $this->kernel->getContainer()->getParameter('router.request_context.base_url');
     } catch (InvalidArgumentException $e) {
         $baseUrl = '';
     }
     try {
         $host = $this->kernel->getContainer()->getParameter('router.request_context.host');
     } catch (InvalidArgumentException $e) {
         $host = 'localhost';
     }
     $requestContext = new RequestContext($baseUrl, $method, $host);
     $router = $this->getRouter();
     $router->setContext($requestContext);
     $urlStack = parse_url($path);
     $info = $router->match($urlStack['path']);
     $route = $info['_route'];
     unset($info['_route']);
     $url = $this->getUrl($route, $info);
     if (isset($urlStack['query'])) {
         $url .= '?' . $urlStack['query'];
     }
     return $url;
 }
开发者ID:GoldenLine,项目名称:WebApiExtension,代码行数:32,代码来源:RouterContext.php

示例2: testServiceIsGettable

 /**
  * Checks if the app can get the service from the container
  */
 public function testServiceIsGettable()
 {
     $serviceCallableName = 'open_exchange_rates_service';
     $this->assertTrue(static::$kernel->getContainer()->has($serviceCallableName));
     static::$kernel->getContainer()->get($serviceCallableName);
     $this->assertTrue(true);
 }
开发者ID:sovaalexandr,项目名称:OpenExchangeRatesBundle,代码行数:10,代码来源:OpenExchangeRatesServiceTest.php

示例3: onKernelRequest

 public function onKernelRequest(GetResponseEvent $event)
 {
     if (!$event->isMasterRequest()) {
         return;
     }
     $request = $event->getRequest();
     $routes = $this->router->getRouteCollection();
     $route = $routes->get($request->attributes->get('_route'));
     if (!$route->getOption('requires_license')) {
         return;
     }
     if ('active' != $request->get('lic') && $this->kernel->getEnvironment() == 'prod') {
         // Checking for whitelisted users
         try {
             $user = $this->tokenStorage->getToken()->getUser();
             $today = date('Y-m-d');
             if ($user instanceof UserInterface) {
                 $whitelist = $this->kernel->getContainer()->getParameter('license_whitelist');
                 foreach ($whitelist as $allowed) {
                     if ($allowed['client_key'] == $user->getClientKey() && $today <= $allowed['valid_till']) {
                         return;
                     }
                 }
             }
         } catch (\Exception $e) {
             // Do nothing
         }
         $url = $this->router->generate('atlassian_connect_unlicensed');
         $response = new RedirectResponse($url);
         $event->setResponse($response);
     }
 }
开发者ID:sainthardaway,项目名称:atlassian-connect-bundle,代码行数:32,代码来源:LicenseListener.php

示例4: theSystemShouldHaveTheFollowingInternetProfiles

 /**
  * @Given the system should have the following internet profiles:
  *
  * @param PyStringNode $body
  *
  */
 public function theSystemShouldHaveTheFollowingInternetProfiles(PyStringNode $body)
 {
     /** @var CollectProfilesTestWorker $collectProfilesTestWorker */
     $collectProfilesTestWorker = $this->kernel->getContainer()->get('muchacuba.internet.collect_profiles_test_worker');
     Assert::assertTrue((new SimpleFactory())->createMatcher()->match(iterator_to_array($collectProfilesTestWorker->collect()), (array) json_decode($body->getRaw(), true)));
     $this->rootContext->ignoreState('Muchacuba\\Internet\\Profile');
 }
开发者ID:nabelhm,项目名称:api,代码行数:13,代码来源:Context.php

示例5: theSystemShouldHaveTheFollowingDebtOperations

 /**
  * @Given the system should have the following recharge card profiles debt operations
  */
 public function theSystemShouldHaveTheFollowingDebtOperations(PyStringNode $body)
 {
     /** @var CollectOperationsTestWorker $collectOperationsTestWorker */
     $collectOperationsTestWorker = $this->kernel->getContainer()->get('muchacuba.recharge_card.profile.debt.collect_operations_test_worker');
     Assert::assertTrue((new SimpleFactory())->createMatcher()->match(iterator_to_array($collectOperationsTestWorker->collect()), (array) json_decode($body->getRaw(), true)));
     $this->rootContext->ignoreState('Muchacuba\\RechargeCard\\Profile\\Debt\\Operation');
 }
开发者ID:nabelhm,项目名称:api,代码行数:10,代码来源:Context.php

示例6: build

 /**
  * @param \Jarves\Configuration\Object[] $objects
  * @param OutputInterface $output
  *
  * @param bool $overwrite
  * @throws ModelBuildException
  */
 public function build(array $objects, OutputInterface $output, $overwrite = false)
 {
     /** @var $jarves \Jarves\Jarves */
     $jarves = $this->kernel->getContainer()->get('jarves');
     $output->writeln('Propel Build');
     foreach ($objects as $object) {
         if ($this->kernel->getContainer()->get($object->getStorageService()) instanceof \Jarves\Storage\Propel) {
             $output->write('Build object ' . $object->getId() . ' => ' . $object->getTable() . ' ... ');
             $bundlePath = $jarves->getBundleDir($object->getBundle()->getName());
             $modelsFile = sprintf('%sResources/config/schema/%s.schema.xml', $bundlePath, strtolower($object->getTable()));
             if (!$overwrite && file_exists($modelsFile) && file_get_contents($modelsFile)) {
                 $xml = @simplexml_load_file($modelsFile);
                 if (false === $xml) {
                     $errors = libxml_get_errors();
                     throw new ModelBuildException(sprintf('Parse error in %s: %s', $modelsFile, json_encode($errors, JSON_PRETTY_PRINT)));
                 }
             } else {
                 $xml = simplexml_load_string('<database></database>');
             }
             $xml['namespace'] = $object->getBundle()->getNamespace() . '\\Model';
             //                $xml['package'] = $object->getBundle()->getNamespace() . '\\Model';
             $xml['name'] = 'default';
             $this->declareTable($xml, $object);
             if (!is_dir(dirname($modelsFile))) {
                 mkdir(dirname($modelsFile), 0777, true);
             }
             file_put_contents($modelsFile, $this->getFormattedXml($xml));
             $output->writeln($modelsFile . ' written.');
             unset($xml);
         }
     }
 }
开发者ID:jarves,项目名称:jarves,代码行数:39,代码来源:Propel.php

示例7: setUp

 public function setUp()
 {
     static::$kernel = static::createKernel();
     static::$kernel->boot();
     $this->dm = static::$kernel->getContainer()->get('doctrine.odm.mongodb.document_manager');
     parent::setUp();
 }
开发者ID:Nameless0ne,项目名称:Aisel,代码行数:7,代码来源:AbstractKernelTestCase.php

示例8: iMustHaveTicketForAllEvents

 /**
  * @Then /^у меня должна быть подписка на все активные ивенты$/
  */
 public function iMustHaveTicketForAllEvents()
 {
     $activeEvents = $this->kernel->getContainer()->get('doctrine')->getManager()->getRepository('StfalconEventBundle:Event')->findBy(array('active' => true));
     $user = $this->kernel->getContainer()->get('fos_user.user_manager')->findUserByEmail('test@fwdays.com');
     $tickets = $this->kernel->getContainer()->get('doctrine')->getManager()->getRepository('StfalconEventBundle:Ticket')->findBy(array('user' => $user->getId()));
     assertEquals(count($tickets), count($activeEvents));
 }
开发者ID:jekakm,项目名称:fwdays,代码行数:10,代码来源:FeatureContext.php

示例9: getFallBackTheme

 /**
  * @return string|null
  */
 protected function getFallBackTheme()
 {
     if (null !== $this->kernel->getContainer()) {
         return $this->kernel->getContainer()->getParameter('fallback_theme');
     }
     return null;
 }
开发者ID:Newman101,项目名称:WellCommerce,代码行数:10,代码来源:ThemeManager.php

示例10: theSystemShouldHaveTheFollowingOperations

 /**
  * @Then the system should have the following info sms subscription low balance reminder logs:
  *
  * @param PyStringNode $body
  */
 public function theSystemShouldHaveTheFollowingOperations(PyStringNode $body)
 {
     /** @var CollectLogsTestWorker $collectLogsTestWorker */
     $collectLogsTestWorker = $this->kernel->getContainer()->get('muchacuba.info_sms.subscription.low_balance_reminder.collect_logs_test_worker');
     Assert::assertTrue((new SimpleFactory())->createMatcher()->match(iterator_to_array($collectLogsTestWorker->collect()), (array) json_decode($body->getRaw(), true)));
     $this->rootContext->ignoreState('Muchacuba\\InfoSms\\Subscription\\LowBalanceReminder\\Log');
 }
开发者ID:nabelhm,项目名称:api,代码行数:12,代码来源:Context.php

示例11: theSystemShouldHaveTheFollowingUniquenesses

 /**
  * @Given the system should have the following uniquenesses:
  */
 public function theSystemShouldHaveTheFollowingUniquenesses(PyStringNode $body)
 {
     /** @var CollectUniquenessTestWorker $collectUniquenessTestWorker */
     $collectUniquenessTestWorker = $this->kernel->getContainer()->get('cubalider.unique.collect_uniqueness_test_worker');
     Assert::assertTrue((new SimpleFactory())->createMatcher()->match(iterator_to_array($collectUniquenessTestWorker->collect()), (array) json_decode($body->getRaw(), true)));
     $this->rootContext->ignoreState('Cubalider\\Uniqueness');
 }
开发者ID:nabelhm,项目名称:api,代码行数:10,代码来源:UniquenessContext.php

示例12: init

 /**
  * @BeforeScenario
  */
 public function init($event)
 {
     $this->translationsApi = $this->kernel->getContainer()->get('jlaso_translations.client.api');
     $apiConfig = $this->kernel->getContainer()->getParameter('jlaso_translations_api_access');
     $this->project_id = 1;
     // cuando se crea de cero siempre es el uno - $apiConfig['project_id'];
     $this->em = $this->kernel->getContainer()->get('doctrine.orm.default_entity_manager');
 }
开发者ID:jlaso,项目名称:translations-apibundle,代码行数:11,代码来源:FeatureContext.php

示例13: getContainer

 /**
  * @return ContainerInterface
  */
 protected function getContainer()
 {
     if ($this->kernel === NULL) {
         $this->kernel = $this->createKernel();
         $this->kernel->boot();
     }
     return $this->kernel->getContainer();
 }
开发者ID:resquebundle,项目名称:resque,代码行数:11,代码来源:ContainerAwareJob.php

示例14: initKernel

 private static function initKernel()
 {
     static::$kernel = static::createKernel();
     static::$kernel->boot();
     static::$container = static::$kernel->getContainer();
     static::$doctrine = static::$container->get('doctrine');
     static::$om = static::$doctrine->getManager();
 }
开发者ID:eugene-matvejev,项目名称:battleship-game-api,代码行数:8,代码来源:AbstractKernelTestSuite.php

示例15: buildClient

 /**
  * Build client
  *
  * @return $this Self object
  */
 public function buildClient()
 {
     $this->kernel = new \AppKernel('test', false);
     $this->kernel->boot();
     $this->session->clear();
     $this->client = $this->kernel->getContainer()->get('test.client');
     $this->environmentBuilder->setUp($this->kernel);
 }
开发者ID:jverdeyen-forks,项目名称:VisithorBundle,代码行数:13,代码来源:SymfonyClient.php


注:本文中的Symfony\Component\HttpKernel\KernelInterface::getContainer方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。