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


PHP HttpKernel\KernelInterface类代码示例

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


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

示例1: let

 /**
  * @param \Symfony\Component\DependencyInjection\ContainerInterface $container_stub
  * @param \Symfony\Component\HttpKernel\KernelInterface $kernel_stub
  */
 function let($container_stub, $kernel_stub)
 {
     $template_path = realpath(__DIR__ . '/../../../../Action/Template/');
     $kernel_stub->locateResource(Argument::any())->willReturn($template_path);
     $container_stub->get(Argument::any())->willReturn($kernel_stub);
     $this->setContainer($container_stub);
 }
开发者ID:artemklv,项目名称:SmirikPropelAdminBundle,代码行数:11,代码来源:ActionManagerSpec.php

示例2: __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

示例3: __construct

 /**
  * Constructor
  *
  * @param KernelInterface $kernel
  */
 public function __construct(KernelInterface $kernel)
 {
     // register email address proxy class loader
     $loader = new UniversalClassLoader();
     $loader->registerNamespaces([self::ENTITY_PROXY_NAMESPACE => $kernel->getCacheDir() . DIRECTORY_SEPARATOR . self::CACHED_ENTITIES_DIR_NAME]);
     $loader->register();
 }
开发者ID:xamin123,项目名称:platform,代码行数:12,代码来源:OroEmailBundle.php

示例4: resolveFixtures

 /**
  * {@inheritdoc}
  */
 public function resolveFixtures(KernelInterface $kernel, array $fixtures)
 {
     $resolvedFixtures = [];
     // Get real fixtures path
     foreach ($fixtures as $index => $fixture) {
         if ($fixture instanceof \SplFileInfo) {
             $filePath = $fixture->getRealPath();
             if (false === $filePath) {
                 throw new \RuntimeException(sprintf('The file %s pointed by a %s instance was not found.', (string) $fixture, get_class($fixture)));
             }
             $fixture = $filePath;
         }
         if (false === is_string($fixture)) {
             throw new \InvalidArgumentException('Expected fixtures passed to be either strings or a SplFileInfo instances.');
         }
         if ('@' === $fixture[0]) {
             // If $kernel fails to resolve the resource, will throw a \InvalidArgumentException exception
             $realPath = $kernel->locateResource($fixture, null, true);
         } else {
             $realPath = realpath($fixture);
         }
         if (false === $realPath || false === file_exists($realPath)) {
             throw new \InvalidArgumentException(sprintf('The file "%s" was not found', $fixture));
         }
         if (false === is_file($realPath)) {
             throw new \InvalidArgumentException(sprintf('Expected "%s to be a fixture file, got a directory instead.', $fixture));
         }
         $resolvedFixtures[$realPath] = true;
     }
     return array_keys($resolvedFixtures);
 }
开发者ID:rznzippy,项目名称:AliceBundle,代码行数:34,代码来源:FixturesFinder.php

示例5: __construct

 /**
  * Constructor
  *
  * @access public
  * @param \Symfony\Component\HttpKernel\KernelInterface $kernel
  */
 public function __construct(KernelInterface $kernel = null)
 {
     $this->bundles = new \SplObjectStorage();
     if ($kernel instanceof KernelInterface) {
         $this->setBundles($kernel->getBundles());
     }
 }
开发者ID:darsyn,项目名称:class-finder,代码行数:13,代码来源:BundleClassFinder.php

示例6: updateKernel

 /**
  * {@inheritDoc}
  * Add the new bundle to the BundleBundle loader infrastructure instead of main kernel
  *
  * @param QuestionHelper  $questionHelper dialog
  * @param InputInterface  $input          input
  * @param OutputInterface $output         output
  * @param KernelInterface $kernel         kernel
  * @param string          $namespace      namespace
  * @param string          $bundle         bundle
  *
  * @return string[]
  */
 protected function updateKernel(QuestionHelper $questionHelper, InputInterface $input, OutputInterface $output, KernelInterface $kernel, $namespace, $bundle)
 {
     // skip if kernel manipulation disabled by options (defaults to true)
     $doUpdate = $input->getOption('doUpdateKernel');
     if ($doUpdate == 'false') {
         return;
     }
     $auto = true;
     if ($input->isInteractive()) {
         $auto = $questionHelper->doAsk($output, $questionHelper->getQuestion('Confirm automatic update of your core bundle', 'yes', '?'));
     }
     $output->write('Enabling the bundle inside the core bundle: ');
     $coreBundle = $kernel->getBundle($input->getOption('loaderBundleName'));
     if (!is_a($coreBundle, '\\Graviton\\BundleBundle\\GravitonBundleInterface')) {
         throw new \LogicException('GravitonCoreBundle does not implement GravitonBundleInterface');
     }
     $manip = new BundleBundleManipulator($coreBundle);
     try {
         $ret = $auto ? $manip->addBundle($namespace . '\\' . $bundle) : false;
         if (!$ret) {
             $reflected = new \ReflectionObject($kernel);
             return array(sprintf('- Edit <comment>%s</comment>', $reflected->getFilename()), '  and add the following bundle in the <comment>GravitonCoreBundle::getBundles()</comment> method:', '', sprintf('    <comment>new %s(),</comment>', $namespace . '\\' . $bundle), '');
         }
     } catch (\RuntimeException $e) {
         return array(sprintf('Bundle <comment>%s</comment> is already defined in <comment>%s)</comment>.', $namespace . '\\' . $bundle, 'sGravitonCoreBundle::getBundles()'), '');
     }
 }
开发者ID:alebon,项目名称:graviton,代码行数:40,代码来源:GenerateBundleCommand.php

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

示例8: importUnits

 /**
  * Imports units.
  *
  * @return array An array with the keys "skipped" and "imported" which contain the number of units skipped and imported
  * @throws \Exception If an error occured
  */
 public function importUnits()
 {
     $path = $this->kernel->locateResource(self::UNIT_PATH . self::UNIT_DATA);
     $yaml = new Parser();
     $data = $yaml->parse(file_get_contents($path));
     $count = 0;
     $skipped = 0;
     foreach ($data as $unitName => $unitData) {
         $unit = $this->getUnit($unitName);
         if ($unit === null) {
             $unit = new Unit();
             $unit->setName($unitName);
             $unit->setSymbol($unitData["symbol"]);
             if (array_key_exists("prefixes", $unitData)) {
                 if (!is_array($unitData["prefixes"])) {
                     throw new \Exception($unitName . " doesn't contain a prefix list, or the prefix list is not an array.");
                 }
                 foreach ($unitData["prefixes"] as $name) {
                     $prefix = $this->getSiPrefix($name);
                     if ($prefix === null) {
                         throw new \Exception("Unable to find SI Prefix " . $name);
                     }
                     $unit->getPrefixes()->add($prefix);
                 }
             }
             $this->entityManager->persist($unit);
             $this->entityManager->flush();
             $count++;
         } else {
             $skipped++;
         }
     }
     return array("imported" => $count, "skipped" => $skipped);
 }
开发者ID:hephaestus9,项目名称:PartKeepr,代码行数:40,代码来源:UnitSetupService.php

示例9: convert

 public function convert($cacheDir)
 {
     $fs = new Filesystem();
     $targetDir = $cacheDir . '/js_entities';
     $webDir = $this->kernel->getRootDir() . '/../web/js';
     $fs->mkdir($targetDir);
     $fs->mkdir($webDir);
     $namespaces = [];
     $metas = $this->entityManager->getMetadataFactory()->getAllMetadata();
     foreach ($metas as $metadata) {
         $meta = $this->convertMetadata($metadata);
         $directory = $targetDir . '/' . $meta->namespace;
         $fs->mkdir($directory);
         $meta->filename = $directory . '/' . $meta->functionName . '.js';
         $this->generator->generateEntity($meta);
         if (!isset($namespaces[$meta->namespace])) {
             $namespaces[$meta->namespace] = array();
         }
         $namespaces[$meta->namespace][] = $meta;
     }
     foreach ($namespaces as $namespace => $metas) {
         $targetFile = $targetDir . '/' . $namespace . '.js';
         $webFile = $webDir . '/' . $namespace . '.js';
         $this->generator->generateNamespace($namespace, $metas, $targetFile);
         $fs->copy($targetFile, $webFile);
     }
 }
开发者ID:CornyPhoenix,项目名称:JsEntitiesBundle,代码行数:27,代码来源:JsEntityConverter.php

示例10: dump

 /**
  * Dumps all translation files.
  *
  * @param string  $targetDir Target directory.
  * @param boolean $symlink   True if generate symlink
  *
  * @return null
  */
 public function dump($targetDir = 'web', $symlink = false, $directory = null)
 {
     $route = $this->router->getRouteCollection()->get('bazinga_exposetranslation_js');
     $directory = null === $directory ? $this->kernel->getRootDir() . '/../' : $directory;
     $requirements = $route->getRequirements();
     $formats = explode('|', $requirements['_format']);
     $routeDefaults = $route->getDefaults();
     $defaultFormat = $routeDefaults['_format'];
     $parts = array_filter(explode('/', $route->getPattern()));
     $this->filesystem->remove($directory . $targetDir . "/" . current($parts));
     foreach ($this->getTranslationMessages() as $locale => $domains) {
         foreach ($domains as $domain => $messageList) {
             foreach ($formats as $format) {
                 $content = $this->engine->render('BazingaExposeTranslationBundle::exposeTranslation.' . $format . '.twig', array('messages' => array($domain => $messageList), 'locale' => $locale, 'defaultDomains' => $domain));
                 $path[$format] = $directory . $targetDir . strtr($route->getPattern(), array('{domain_name}' => $domain, '{_locale}' => $locale, '{_format}' => $format));
                 $this->filesystem->mkdir(dirname($path[$format]), 0777);
                 if (file_exists($path[$format])) {
                     $this->filesystem->remove($path[$format]);
                 }
                 file_put_contents($path[$format], $content);
             }
             $targetFile = $directory . $targetDir;
             $targetFile .= strtr($route->getPattern(), array('{domain_name}' => $domain, '{_locale}' => $locale, '.{_format}' => ''));
             if (true === $symlink) {
                 $this->filesystem->symlink($path[$defaultFormat], $targetFile);
             } else {
                 $this->filesystem->copy($path[$defaultFormat], $targetFile);
             }
         }
     }
 }
开发者ID:ashutosh-srijan,项目名称:findit_akeneo,代码行数:39,代码来源:TranslationDumper.php

示例11: execute

 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $noInitialize = $input->getOption('no-initialize');
     $append = $input->getOption('append');
     if ($input->isInteractive() && !$append) {
         $dialog = $this->getHelperSet()->get('dialog');
         $confirmed = $dialog->askConfirmation($output, '<question>Careful, database will be purged. Do you want to continue Y/N ?</question>', false);
         if (!$confirmed) {
             return 0;
         }
     }
     $paths = $input->getOption('fixtures');
     $candidatePaths = [];
     if (!$paths) {
         $paths = [];
         foreach ($this->kernel->getBundles() as $bundle) {
             $candidatePath = $bundle->getPath() . '/DataFixtures/Document';
             $candidatePaths[] = $candidatePath;
             if (file_exists($candidatePath)) {
                 $paths[] = $candidatePath;
             }
         }
     }
     if (empty($paths)) {
         $output->writeln('<info>Could not find any candidate fixture paths.</info>');
         if ($input->getOption('verbose')) {
             $output->writeln(sprintf('Looked for: </comment>%s<comment>"</comment>', implode('"<comment>", "</comment>', $candidatePaths)));
         }
         return 0;
     }
     $fixtures = $this->loader->load($paths);
     $this->executor->execute($fixtures, false === $append, false === $noInitialize, $output);
     $output->writeln('');
     $output->writeln(sprintf('<info>Done. Executed </info>%s</info><info> fixtures.</info>', count($fixtures)));
 }
开发者ID:Silwereth,项目名称:sulu,代码行数:38,代码来源:FixturesLoadCommand.php

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

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

示例14: extract

 /**
  * @param string $source
  * @param string $locale
  *
  * @return MessageCatalogueInterface | null
  */
 public function extract($source, $locale)
 {
     if (!$this->isSourceAvailable($source)) {
         return;
     }
     $fs = new Filesystem();
     /* @var Bundle $foundBundle */
     $foundBundle = $this->kernel->getBundle($this->bundle);
     // load any messages from templates
     $extractedCatalogue = new MessageCatalogue($locale);
     $resourcesDir = $this->resolveResourcesDirectory($foundBundle);
     if ($fs->exists($resourcesDir)) {
         $this->extractor->extract($resourcesDir, $extractedCatalogue);
     }
     // load any existing messages from the translation files
     $translationsDir = $foundBundle->getPath() . '/Resources/translations';
     if ($fs->exists($translationsDir)) {
         $currentCatalogue = new MessageCatalogue($locale);
         $this->loader->loadMessages($translationsDir, $currentCatalogue);
         foreach ($extractedCatalogue->getDomains() as $domain) {
             $messages = $currentCatalogue->all($domain);
             if (count($messages)) {
                 $extractedCatalogue->add($messages, $domain);
             }
         }
     }
     return $extractedCatalogue;
 }
开发者ID:modera,项目名称:foundation,代码行数:34,代码来源:TemplateTranslationHandler.php

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


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