本文整理汇总了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');
}
示例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()}");
}
示例3: setUp
/**
* @return null
*/
public function setUp()
{
$this->kernel = new \AppKernel('test', true);
$this->kernel->boot();
$this->container = $this->kernel->getContainer();
parent::setUp();
}
示例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();
}
}
示例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());
}
}
示例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);
}
示例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'));
}
示例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'])));
}
示例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());
}
示例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);
}
示例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;
}
示例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();
}
示例13: __construct
/**
* CoreParametersHelper constructor.
*
* @param Kernel $kernel
*/
public function __construct(Kernel $kernel)
{
$this->parameterBag = $kernel->getContainer()->getParameterBag();
}
示例14: __construct
public function __construct(Kernel $kernel)
{
$filePath = $kernel->getContainer()->getParameter('maxmind_geoip_data_file_path');
$this->geoip = new GeoIp($filePath);
}
示例15: testParameter
/**
* @covers ::load
*/
public function testParameter()
{
$container = $this->kernel->getContainer();
$this->assertTrue($container->hasParameter('faker.locale'));
$this->assertTrue($container->hasParameter('faker.seed'));
}