getContainer() public méthode

public getContainer ( )
 /**
  * @before
  *
  */
 protected function setUpSymfonyKernel()
 {
     $this->kernel = $this->createKernel();
     $this->kernel->boot();
     $this->container = $this->kernel->getContainer();
     $this->logger = $this->container->get('logger');
 }
 /**
  * {@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()}");
 }
 /**
  * @return null
  */
 public function setUp()
 {
     $this->kernel = new \AppKernel('test', true);
     $this->kernel->boot();
     $this->container = $this->kernel->getContainer();
     parent::setUp();
 }
 /**
  * @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();
     }
 }
 /**
  * @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());
     }
 }
 /**
  * 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);
 }
 /**
  * @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'));
 }
 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'])));
 }
Exemple #9
0
 /**
  * @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());
 }
Exemple #10
0
 /**
  * @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);
 }
 /**
  * Loads the ContainerBuilder from the cache.
  *
  * @author Ryan Weaver <*****@*****.**>
  *
  */
 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;
 }
 /**
  * @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();
 }
 /**
  * CoreParametersHelper constructor.
  *
  * @param Kernel $kernel
  */
 public function __construct(Kernel $kernel)
 {
     $this->parameterBag = $kernel->getContainer()->getParameterBag();
 }
 public function __construct(Kernel $kernel)
 {
     $filePath = $kernel->getContainer()->getParameter('maxmind_geoip_data_file_path');
     $this->geoip = new GeoIp($filePath);
 }
 /**
  * @covers ::load
  */
 public function testParameter()
 {
     $container = $this->kernel->getContainer();
     $this->assertTrue($container->hasParameter('faker.locale'));
     $this->assertTrue($container->hasParameter('faker.seed'));
 }
 /**
  * @return ContainerInterface
  */
 private function getContainer()
 {
     return $this->kernel->getContainer();
 }
 /**
  * Return container.
  *
  * @return ContainerInterface
  */
 public function _getContainer()
 {
     return $this->kernel->getContainer();
 }
Exemple #18
0
 /**
  * TemplatingHelper constructor.
  * 
  * @param Kernel $kernel
  */
 public function __construct(Kernel $kernel)
 {
     $this->container = $kernel->getContainer();
 }
 private function pluginIsLoaded(Kernel $httpKernel, BundlePlugin $plugin)
 {
     $this->assertTrue($httpKernel->getContainer()->hasParameter($plugin->name() . '.loaded'));
     $this->assertTrue($plugin::$built);
     $this->assertTrue($plugin::$booted);
 }
 /**
  * @test
  * @functional
  */
 public function testServiceAvailability()
 {
     $this->assertInstanceOf('Github\\Client', $this->kernel->getContainer()->get('github.client'));
     $this->assertInstanceOf('Github\\HttpClient\\HttpClient', $this->kernel->getContainer()->get('github.http.client'));
     $this->assertInstanceOf('Github\\HttpClient\\Cache\\FilesystemCache', $this->kernel->getContainer()->get('github.http.cache'));
 }