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


PHP Kernel::getContainer方法代码示例

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


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

示例1: setUpSymfonyKernel

 /**
  * @before
  *
  */
 protected function setUpSymfonyKernel()
 {
     $this->kernel = $this->createKernel();
     $this->kernel->boot();
     $this->container = $this->kernel->getContainer();
     $this->logger = $this->container->get('logger');
 }
开发者ID:CarnegieLearningWeb,项目名称:ldap-orm-bundle,代码行数:11,代码来源:SymfonyKernel.php

示例2: locate

 /**
  * {@inheritdoc}
  */
 public function locate($resource, GeneratorInterface $generator)
 {
     $bundles = $this->kernel->getBundles();
     $class = get_class($generator);
     $appResources = $this->kernel->getContainer()->getParameter('kernel.root_dir') . '/Resources/';
     $location = "skeleton/{$generator->getName()}/{$resource}";
     /** @var Bundle $bundle */
     foreach ($bundles as $bundle) {
         if (strpos($class, $bundle->getNamespace()) !== false) {
             $global = "{$appResources}/{$bundle->getName()}/{$location}";
             if (file_exists($global) && is_readable($global)) {
                 return $global;
             } else {
                 $local = "{$bundle->getPath()}/Resources/{$location}";
                 if (file_exists($local) && is_readable($local)) {
                     return $local;
                 } else {
                     throw new ResourceNotFoundException("Resource {$resource} could not be located for generator {$generator->getName()}");
                 }
             }
         }
     }
     $nonBundle = "{$appResources}{$location}";
     if (file_exists($nonBundle) && is_readable($nonBundle)) {
         return $nonBundle;
     }
     throw new ResourceNotFoundException("Resource {$resource} could not be located for generator {$generator->getName()}");
 }
开发者ID:tweedegolf,项目名称:generatorbundle,代码行数:31,代码来源:SymfonyResourceLocator.php

示例3: setUp

 /**
  * @return null
  */
 public function setUp()
 {
     $this->kernel = new \AppKernel('test', true);
     $this->kernel->boot();
     $this->container = $this->kernel->getContainer();
     parent::setUp();
 }
开发者ID:uikolas,项目名称:LT-eshops-search,代码行数:10,代码来源:KernelAwareTest.php

示例4: setUpDatabase

 /**
  * @before
  */
 public function setUpDatabase()
 {
     if (isset($_SERVER['IS_DOCTRINE_ORM_SUPPORTED']) && $_SERVER['IS_DOCTRINE_ORM_SUPPORTED']) {
         $this->entityManager = static::$sharedKernel->getContainer()->get('doctrine.orm.entity_manager');
         $this->purgeDatabase();
     }
 }
开发者ID:steffenbrem,项目名称:ApiTestCase,代码行数:10,代码来源:ApiTestCase.php

示例5: pluginIs

 /**
  * @param bool $loaded
  * @param Kernel $kernel
  * @param string $pluginName
  */
 private function pluginIs($loaded, Kernel $kernel, $pluginName)
 {
     $this->assertSame($loaded, $kernel->getContainer()->hasParameter($pluginName . '.loaded'));
     $this->assertSame($loaded, $kernel->getContainer()->hasParameter($pluginName . '.build_was_called'));
     if ($kernel->getContainer()->has($pluginName . 'boot')) {
         $this->assertSame($loaded, $kernel->getContainer()->get($pluginName . '.boot')->wasCalled());
     }
 }
开发者ID:ad3n,项目名称:BundlePlugin,代码行数:13,代码来源:BundleWithPluginsTest.php

示例6: _____testSimpleException

 /**
  * Rename for local development by removing underscores.
  */
 public function _____testSimpleException()
 {
     $request = $this->buildRequest();
     $exception = new \RuntimeException('Hello', 404, new \InvalidArgumentException('Invalid argument, or something', 500));
     $exception = FlattenException::create($exception);
     $context = array('a' => 'b', 'c' => array('x' => 'y', array('t' => 'q')));
     $body = $this->_kernel->getContainer()->get('templating')->render('EhoughEmailErrorsBundle::mail.html.twig', array('exception' => $exception, 'request' => $request, 'context' => $context, 'status_text' => Response::$statusTexts[$exception->getStatusCode()]));
     file_put_contents('/tmp/out.txt', $body);
 }
开发者ID:ehough,项目名称:emailerrors-bundle,代码行数:12,代码来源:MailTemplateTest.php

示例7: testService

 /**
  * @covers ::load
  */
 public function testService()
 {
     $container = $this->kernel->getContainer();
     $salvaAsseticFilter = $container->getParameter('salva_assetic_filter.jshrink.class');
     $salvaTwigExtension = $container->getParameter('salva_twig_extension.jshrink.class');
     $this->assertTrue($container->has('salva_assetic_filter.jshrink'));
     $this->assertTrue($container->has('salva_twig_extension.jshrink'));
     $this->assertInstanceOf($salvaAsseticFilter, $container->get('salva_assetic_filter.jshrink'));
     $this->assertInstanceOf($salvaTwigExtension, $container->get('salva_twig_extension.jshrink'));
 }
开发者ID:nibsirahsieu,项目名称:SalvaJshrinkBundle,代码行数:13,代码来源:SalvaJshrinkExtensionTest.php

示例8: generateCertificate

 private function generateCertificate($domain, array $csrConfig = [])
 {
     $defaultConfig = $this->getDefaultConfig();
     $defaultConfig['default_distinguished_name']['email_address'] = $defaultConfig['contact_email'];
     $csrConfig = $defaultConfig['default_distinguished_name'] + $csrConfig;
     $this->kernel->getContainer()->get('acme_php.certificate.requester')->requestCertificate(new DomainConfiguration($domain, new CSR($csrConfig['country'], $csrConfig['state'], $csrConfig['locality'], $csrConfig['organization_name'], $csrConfig['organization_unit_name'], $csrConfig['email_address'])));
 }
开发者ID:acmephp,项目名称:symfony-bundle,代码行数:7,代码来源:FeatureContext.php

示例9: getProfiler

 /**
  * @return \Symfony\Component\HttpKernel\Profiler\Profile
  */
 protected function getProfiler()
 {
     if (!$this->kernel->getContainer()->has('profiler')) {
         return null;
     }
     $profiler = $this->kernel->getContainer()->get('profiler');
     return $profiler->loadProfileFromResponse($this->client->getResponse());
 }
开发者ID:NaszvadiG,项目名称:ImageCMS,代码行数:11,代码来源:Symfony2.php

示例10: getProfiler

 /**
  * @return \Symfony\Component\HttpKernel\Profiler\Profile
  */
 protected function getProfiler()
 {
     if (!$this->kernel->getContainer()->has('profiler')) {
         return null;
     }
     $profiler = $this->kernel->getContainer()->get('profiler');
     $response = $this->client->getResponse();
     if (null === $response) {
         $this->fail("You must perform a request before using this method.");
     }
     return $profiler->loadProfileFromResponse($response);
 }
开发者ID:hitechdk,项目名称:Codeception,代码行数:15,代码来源:Symfony2.php

示例11: loadContainerBuilder

 /**
  * Loads the ContainerBuilder from the cache.
  *
  * @author Ryan Weaver <ryan@thatsquality.com>
  *
  */
 private function loadContainerBuilder()
 {
     if ($this->containerBuilder !== null) {
         return;
     }
     $container = $this->kernel->getContainer();
     if (!$this->getKernel()->isDebug() || !$container->hasParameter('debug.container.dump') || !file_exists($cachedFile = $container->getParameter('debug.container.dump'))) {
         $this->containerBuilder = false;
         return;
     }
     $containerBuilder = new ContainerBuilder();
     $loader = new XmlFileLoader($containerBuilder, new FileLocator());
     $loader->load($cachedFile);
     $this->containerBuilder = $containerBuilder;
 }
开发者ID:LittleTwoCheng,项目名称:WebProfilerExtraBundle,代码行数:21,代码来源:ContainerDataCollector.php

示例12: getInstance

 /**
  * @param bool $useFakeController
  *
  * @return \CI_Controller
  * @throws \Exception
  */
 public function getInstance($useFakeController = true)
 {
     $this->unsetNoticeErrorLevel();
     if (function_exists('get_instance')) {
         self::$ciLoaded = true;
     }
     if (!self::$ciLoaded) {
         self::$ciLoaded = true;
         if ($this->kernel->getContainer()->isScopeActive('request')) {
             $this->setCiPaths($this->kernel->getContainer()->get('request'));
         } else {
             $this->setCiPaths();
         }
         require_once __DIR__ . '/ci_bootstrap.php';
         \ci_bootstrap($this->kernel, $this->overrideControllerClass, $useFakeController);
         // load without calling CodeIgniter method but initiating CI class
     }
     return \get_instance();
 }
开发者ID:BahuL,项目名称:NercuryCodeIgniterBundle,代码行数:25,代码来源:CiHelperService.php

示例13: __construct

 /**
  * CoreParametersHelper constructor.
  *
  * @param Kernel $kernel
  */
 public function __construct(Kernel $kernel)
 {
     $this->parameterBag = $kernel->getContainer()->getParameterBag();
 }
开发者ID:dongilbert,项目名称:mautic,代码行数:9,代码来源:CoreParametersHelper.php

示例14: __construct

 public function __construct(Kernel $kernel)
 {
     $filePath = $kernel->getContainer()->getParameter('maxmind_geoip_data_file_path');
     $this->geoip = new GeoIp($filePath);
 }
开发者ID:Platzengys,项目名称:Maxmind-GeoIp,代码行数:5,代码来源:GeoipManager.php

示例15: testParameter

 /**
  * @covers ::load
  */
 public function testParameter()
 {
     $container = $this->kernel->getContainer();
     $this->assertTrue($container->hasParameter('faker.locale'));
     $this->assertTrue($container->hasParameter('faker.seed'));
 }
开发者ID:resing,项目名称:ecommerce,代码行数:9,代码来源:FakerExtensionTest.php


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