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


PHP KernelInterface::getEnvironment方法代码示例

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


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

示例1: 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

示例2: process

 /**
  * {@inheritDoc}
  */
 public function process(ContainerBuilder $container)
 {
     if ('test' === $this->kernel->getEnvironment()) {
         $definition = $container->getDefinition('translator.default');
         $definition->setClass('Braincrafted\\Bundle\\TestingBundle\\Translator\\NoTranslator');
     }
 }
开发者ID:braincrafted,项目名称:testing-bundle,代码行数:10,代码来源:TranslatorCompilerPass.php

示例3: __construct

 /**
  * Constructor.
  *
  * @param KernelInterface $kernel A KernelInterface instance
  */
 public function __construct(KernelInterface $kernel)
 {
     $this->kernel = $kernel;
     parent::__construct('Symfony', Kernel::VERSION . ' - ' . $kernel->getName() . '/' . $kernel->getEnvironment() . ($kernel->isDebug() ? '/debug' : ''));
     $this->getDefinition()->addOption(new InputOption('--env', '-e', InputOption::VALUE_REQUIRED, 'The Environment name.', $kernel->getEnvironment()));
     $this->getDefinition()->addOption(new InputOption('--no-debug', null, InputOption::VALUE_NONE, 'Switches off debug mode.'));
 }
开发者ID:Ener-Getick,项目名称:symfony,代码行数:12,代码来源:Application.php

示例4: onConsoleTerminate

 /**
  * @param ConsoleTerminateEvent $event
  */
 public function onConsoleTerminate(ConsoleTerminateEvent $event)
 {
     $command = $event->getCommand();
     $environment = $this->kernel->getEnvironment();
     if ($environment == 'test' && $command instanceof LoadMigrationsCommand && $event->getInput()->getOption('force')) {
         $executor = new CommandExecutor($environment, $event->getOutput(), $command->getApplication());
         $executor->runCommand('oro:test:schema:update', ['--process-isolation' => true]);
     }
 }
开发者ID:northdakota,项目名称:platform,代码行数:12,代码来源:UpdateSchemaListener.php

示例5: getCoreBundlesClasses

 /**
  * @return array
  */
 protected function getCoreBundlesClasses()
 {
     $bundles = [\Symfony\Bundle\FrameworkBundle\FrameworkBundle::class, \Symfony\Bundle\SecurityBundle\SecurityBundle::class, \Symfony\Bundle\TwigBundle\TwigBundle::class, \Symfony\Bundle\MonologBundle\MonologBundle::class, \Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle::class, \Doctrine\Bundle\DoctrineBundle\DoctrineBundle::class, \Doctrine\Bundle\DoctrineCacheBundle\DoctrineCacheBundle::class, \Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle::class, \Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle::class, \Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle::class, \FOS\JsRoutingBundle\FOSJsRoutingBundle::class, \Bazinga\Bundle\JsTranslationBundle\BazingaJsTranslationBundle::class, \Liip\ImagineBundle\LiipImagineBundle::class, \Knp\DoctrineBehaviors\Bundle\DoctrineBehaviorsBundle::class, \Cache\AdapterBundle\CacheAdapterBundle::class, \WellCommerce\Bundle\AppBundle\WellCommerceAppBundle::class];
     if (in_array($this->kernel->getEnvironment(), ['dev', 'test'])) {
         $bundles[] = \Symfony\Bundle\WebProfilerBundle\WebProfilerBundle::class;
         $bundles[] = \Sensio\Bundle\GeneratorBundle\SensioGeneratorBundle::class;
     }
     return $bundles;
 }
开发者ID:wellcommerce,项目名称:wellcommerce,代码行数:12,代码来源:BundleLoader.php

示例6: __construct

 /**
  * Constructor.
  *
  * @param KernelInterface $kernel A KernelInterface instance
  */
 public function __construct(KernelInterface $kernel)
 {
     $this->kernel = $kernel;
     parent::__construct('Symfony', Kernel::VERSION . ' - ' . $kernel->getName() . '/' . $kernel->getEnvironment() . ($kernel->isDebug() ? '/debug' : ''));
     $this->getDefinition()->addOption(new InputOption('--shell', '-s', InputOption::VALUE_NONE, 'Launch the shell.'));
     $this->getDefinition()->addOption(new InputOption('--process-isolation', null, InputOption::VALUE_NONE, 'Launch commands from shell as a separate processes.'));
     $this->getDefinition()->addOption(new InputOption('--env', '-e', InputOption::VALUE_REQUIRED, 'The Environment name.', $kernel->getEnvironment()));
     $this->getDefinition()->addOption(new InputOption('--no-debug', null, InputOption::VALUE_NONE, 'Switches off debug mode.'));
 }
开发者ID:TeamA-ict,项目名称:TeamA,代码行数:14,代码来源:Application.php

示例7: onKernelResponse

 public function onKernelResponse(FilterResponseEvent $event)
 {
     if (!in_array($this->kernel->getEnvironment(), array('test', 'dev'))) {
         $response = $event->getResponse();
         $compressedContent = new HtmlCompressor($response->getContent());
         $response->setContent($compressedContent->compress());
         return $response;
     }
 }
开发者ID:ihsanudin,项目名称:compressor,代码行数:9,代码来源:HtmlCompressorOutputFilter.php

示例8: getKernel

 /**
  * @return KernelInterface
  */
 private function getKernel(InputInterface $input)
 {
     $env = $input->getParameterOption(['--env', '-e'], $this->baseKernel->getEnvironment());
     $debug = !$input->hasParameterOption(['--no-debug', '']);
     if ($env === $this->baseKernel->getEnvironment() && $debug === $this->baseKernel->isDebug()) {
         return $this->baseKernel;
     }
     $kernelClass = new ReflectionClass($this->baseKernel);
     return $kernelClass->newInstance([$env, $debug]);
 }
开发者ID:blutch89,项目名称:library-sf2,代码行数:13,代码来源:CommandExecuter.php

示例9: collect

 /**
  * {@inheritdoc}
  */
 public function collect(Request $request, Response $response, \Exception $exception = null)
 {
     $this->data = array('app_name' => $this->name, 'app_version' => $this->version, 'token' => $response->headers->get('X-Debug-Token'), 'symfony_version' => Kernel::VERSION, 'symfony_state' => 'unknown', 'name' => isset($this->kernel) ? $this->kernel->getName() : 'n/a', 'env' => isset($this->kernel) ? $this->kernel->getEnvironment() : 'n/a', 'debug' => isset($this->kernel) ? $this->kernel->isDebug() : 'n/a', 'php_version' => PHP_VERSION, 'xdebug_enabled' => extension_loaded('xdebug'), 'eaccel_enabled' => extension_loaded('eaccelerator') && ini_get('eaccelerator.enable'), 'apc_enabled' => extension_loaded('apc') && ini_get('apc.enabled'), 'xcache_enabled' => extension_loaded('xcache') && ini_get('xcache.cacher'), 'wincache_enabled' => extension_loaded('wincache') && ini_get('wincache.ocenabled'), 'zend_opcache_enabled' => extension_loaded('Zend OPcache') && ini_get('opcache.enable'), 'bundles' => array(), 'sapi_name' => PHP_SAPI);
     if (isset($this->kernel)) {
         foreach ($this->kernel->getBundles() as $name => $bundle) {
             $this->data['bundles'][$name] = $bundle->getPath();
         }
         $this->data['symfony_state'] = $this->determineSymfonyState();
     }
 }
开发者ID:yceruto,项目名称:symfony,代码行数:13,代码来源:ConfigDataCollector.php

示例10: populate

 /**
  * {@inheritdoc}
  */
 public function populate(EntityManager $em = null)
 {
     $process = new Process(sprintf("%s/console fos:elastica:populate --env=%s", $this->kernel->getRootDir(), $this->kernel->getEnvironment()));
     $process->run();
     if (!$process->isSuccessful()) {
         throw new \RuntimeException($process->getErrorOutput());
     }
     $this->output = $process->getOutput();
     return $this;
 }
开发者ID:Strontium-90,项目名称:Sylius,代码行数:13,代码来源:ElasticsearchIndexer.php

示例11: getCoreBundlesClasses

 private function getCoreBundlesClasses() : array
 {
     $bundles = [FrameworkBundle::class, SecurityBundle::class, TwigBundle::class, MonologBundle::class, SwiftmailerBundle::class, DoctrineBundle::class, DoctrineCacheBundle::class, DoctrineMigrationsBundle::class, DoctrineFixturesBundle::class, SensioFrameworkExtraBundle::class, FOSJsRoutingBundle::class, BazingaJsTranslationBundle::class, LiipImagineBundle::class, DoctrineBehaviorsBundle::class, CacheAdapterBundle::class, TwigCacheBundle::class];
     if (in_array($this->kernel->getEnvironment(), ['dev', 'test'])) {
         $bundles[] = WebProfilerBundle::class;
         $bundles[] = SensioGeneratorBundle::class;
     }
     if (in_array($this->kernel->getEnvironment(), ['prod'])) {
         $bundles[] = WebProfilerBundle::class;
     }
     return $bundles;
 }
开发者ID:WellCommerce,项目名称:DistributionBundle,代码行数:12,代码来源:BundleLoader.php

示例12: onKernelException

 public function onKernelException(GetResponseForExceptionEvent $event)
 {
     if ($this->kernel->getEnvironment() === 'prod') {
         $exception = $event->getException();
         if ($exception instanceof HttpExceptionInterface) {
             $status_code = $exception->getStatusCode();
         } else {
             $status_code = 500;
         }
         $response = new Response($this->getTwig()->render('rootiovmailmeBundle::error.html.twig', array('status_code' => $status_code)));
         $event->setResponse($response);
     }
 }
开发者ID:bartuspan,项目名称:vmail,代码行数:13,代码来源:ExceptionListener.php

示例13: populate

 /**
  * {@inheritdoc}
  */
 public function populate(EntityManager $em = null)
 {
     $command = new PopulateCommand();
     $command->setContainer($this->kernel->getContainer());
     $output = new BufferedOutput();
     $input = new ArgvInput(['env' => $this->kernel->getEnvironment()]);
     if ($command->run($input, $output)) {
         //return code is not zero
         throw new \RuntimeException($output->fetch());
     }
     $this->output = $output->fetch();
     return $this;
 }
开发者ID:aleherse,项目名称:Sylius,代码行数:16,代码来源:ElasticsearchIndexer.php

示例14: onKernelException

 public function onKernelException(GetResponseForExceptionEvent $event)
 {
     if ('prod' !== $this->kernel->getEnvironment()) {
         return;
     }
     $exception = $event->getException();
     $response = new Response();
     $response->setStatusCode(Response::HTTP_INTERNAL_SERVER_ERROR);
     if ($exception instanceof HttpExceptionInterface) {
         if (400 < $exception->getStatusCode() && 500 > $exception->getStatusCode()) {
             $response->setStatusCode(Response::HTTP_NOT_FOUND);
             $response->headers->replace($exception->getHeaders());
         }
     }
     $event->setResponse($response);
 }
开发者ID:ucay,项目名称:Skeleton,代码行数:16,代码来源:ExceptionListener.php

示例15: __construct

 public function __construct(KernelInterface $kernel)
 {
     $this->kernel = $kernel;
     parent::__construct("Thelia", Thelia::THELIA_VERSION);
     $this->getDefinition()->addOption(new InputOption('--env', '-e', InputOption::VALUE_REQUIRED, 'The Environment name.', $kernel->getEnvironment()));
     $this->getDefinition()->addOption(new InputOption('--no-debug', null, InputOption::VALUE_NONE, 'Switches off debug mode.'));
 }
开发者ID:badelas,项目名称:thelia,代码行数:7,代码来源:Application.php


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