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


PHP KernelInterface::getRootDir方法代码示例

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


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

示例1: getLocations

 /**
  * Gets translation files location.
  *
  * @return array
  */
 private function getLocations()
 {
     $locations = array();
     if (class_exists('Symfony\\Component\\Validator\\Validator')) {
         $r = new \ReflectionClass('Symfony\\Component\\Validator\\Validator');
         $locations[] = dirname($r->getFilename()) . '/Resources/translations';
     }
     if (class_exists('Symfony\\Component\\Form\\Form')) {
         $r = new \ReflectionClass('Symfony\\Component\\Form\\Form');
         $locations[] = dirname($r->getFilename()) . '/Resources/translations';
     }
     if (class_exists('Symfony\\Component\\Security\\Core\\Exception\\AuthenticationException')) {
         $r = new \ReflectionClass('Symfony\\Component\\Security\\Core\\Exception\\AuthenticationException');
         if (file_exists($dir = dirname($r->getFilename()) . '/../../Resources/translations')) {
             $locations[] = $dir;
         } else {
             // Symfony 2.4 and above
             $locations[] = dirname($r->getFilename()) . '/../Resources/translations';
         }
     }
     $overridePath = $this->kernel->getRootDir() . '/Resources/%s/translations';
     foreach ($this->kernel->getBundles() as $bundle => $class) {
         $reflection = new \ReflectionClass($class);
         if (is_dir($dir = dirname($reflection->getFilename()) . '/Resources/translations')) {
             $locations[] = $dir;
         }
         if (is_dir($dir = sprintf($overridePath, $bundle))) {
             $locations[] = $dir;
         }
     }
     if (is_dir($dir = $this->kernel->getRootDir() . '/Resources/translations')) {
         $locations[] = $dir;
     }
     return $locations;
 }
开发者ID:simplesurance,项目名称:BazingaJsTranslationBundle,代码行数:40,代码来源:TranslationFinder.php

示例2: deleteDatabaseIfExist

 /**
  * @AfterScenario
  */
 public function deleteDatabaseIfExist()
 {
     $dbFilePath = $this->kernel->getRootDir() . '/data.sqlite';
     if (file_exists($dbFilePath)) {
         unlink($dbFilePath);
     }
 }
开发者ID:szymach,项目名称:admin-security-bundle,代码行数:10,代码来源:AdminUserContext.php

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

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

示例5: createFile

 /**
  * @Given there is a file named :filename with:
  */
 public function createFile($filename, PyStringNode $content)
 {
     $filesytem = new Filesystem();
     $file = str_replace('%kernel.root_dir%', $this->kernel->getRootDir(), $filename);
     $filesytem->mkdir(dirname($file));
     file_put_contents($file, (string) $content);
 }
开发者ID:symfony-cmf,项目名称:resource-rest-bundle,代码行数:10,代码来源:ResourceContext.php

示例6: createNavigator

 /**
  * @param JsonCoder $jsonCoder
  * @return Raml\DocNavigator
  */
 public function createNavigator(JsonCoder $jsonCoder)
 {
     $ramlDocPath = $this->kernel->getRootDir() . static::RAML_DOC_PATH;
     if (!is_readable($ramlDocPath)) {
         throw new \RuntimeException(static::ERROR_PARAM_TYPE);
     }
     $ramlDoc = $this->parser->parse($ramlDocPath);
     return new Raml\DocNavigator($ramlDoc, $jsonCoder);
 }
开发者ID:mb3rnard,项目名称:hateoas-bundle,代码行数:13,代码来源:RamlNavigatorFactory.php

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

示例8: getPossibleViewDirectories

 /**
  * Returns paths to directories that *might* contain Twig views.
  *
  * Please note, that it is not guaranteed that these directories exist.
  *
  * @return string[]
  */
 protected function getPossibleViewDirectories()
 {
     $viewDirectories = array();
     $globalResourceDirectory = $this->kernel->getRootDir() . '/Resources';
     $viewDirectories[] = $globalResourceDirectory;
     foreach ($this->kernel->getBundles() as $bundle) {
         /* @var $bundle BundleInterface */
         $viewDirectory = $bundle->getPath() . '/Resources/views';
         $viewDirectories[] = $viewDirectory;
     }
     return $viewDirectories;
 }
开发者ID:webfactory,项目名称:symfony-application-tests,代码行数:19,代码来源:TwigTemplateIterator.php

示例9: describeWorker

 /**
  * Describe Worker.
  *
  * Given a output object and a Worker, dscribe it.
  *
  * @param OutputInterface $output             Output object
  * @param array           $worker             Worker array with Job to describe
  * @param Boolean         $tinyJobDescription If true also print job list
  */
 public function describeWorker(OutputInterface $output, array $worker, $tinyJobDescription = false)
 {
     /**
      * Commandline
      */
     $script = $this->kernel->getRootDir() . '/console gearman:worker:execute';
     $output->writeln('');
     $output->writeln('<info>@Worker\\className : ' . $worker['className'] . '</info>');
     $output->writeln('<info>@Worker\\fileName : ' . $worker['fileName'] . '</info>');
     $output->writeln('<info>@Worker\\nameSpace : ' . $worker['namespace'] . '</info>');
     $output->writeln('<info>@Worker\\callableName: ' . $worker['callableName'] . '</info>');
     /**
      * Also a complete and clean execution path is given , for supervisord
      */
     $output->writeln('<info>@Worker\\supervisord : </info><comment>/usr/bin/php ' . $script . ' ' . $worker['callableName'] . ' --no-interaction</comment>');
     /**
      * Service value is only explained if defined. Not mandatory
      */
     if (null !== $worker['service']) {
         $output->writeln('<info>@Worker\\service : ' . $worker['service'] . '</info>');
     }
     $output->writeln('<info>@worker\\iterations : ' . $worker['iterations'] . '</info>');
     $output->writeln('<info>@Worker\\#jobs : ' . count($worker['jobs']) . '</info>');
     if ($tinyJobDescription) {
         $output->writeln('<info>@Worker\\jobs</info>');
         $output->writeln('');
         foreach ($worker['jobs'] as $job) {
             if ($job['jobPrefix']) {
                 $output->writeln('<comment>    # ' . $job['realCallableNameNoPrefix'] . ' with jobPrefix: ' . $job['jobPrefix'] . '</comment>');
             } else {
                 $output->writeln('<comment>    # ' . $job['realCallableNameNoPrefix'] . ' </comment>');
             }
         }
     }
     /**
      * Printed every server is defined for current job
      */
     $output->writeln('');
     $output->writeln('<info>@worker\\servers :</info>');
     $output->writeln('');
     foreach ($worker['servers'] as $name => $server) {
         $output->writeln('<comment>    #' . $name . ' - ' . $server['host'] . ':' . $server['port'] . '</comment>');
     }
     /**
      * Description
      */
     $output->writeln('');
     $output->writeln('<info>@Worker\\description :</info>');
     $output->writeln('');
     $output->writeln('<comment>    ' . $worker['description'] . '</comment>');
     $output->writeln('');
 }
开发者ID:eduardtrandafir,项目名称:gearman-bundle,代码行数:61,代码来源:GearmanDescriber.php

示例10: getProjectDir

 /**
  * @return string
  */
 public function getProjectDir()
 {
     $filesystem = new Filesystem();
     $lastPath = realpath($this->kernel->getRootDir());
     $parentCount = substr_count($lastPath, DIRECTORY_SEPARATOR);
     for ($i = 0; $i < $parentCount; $i++) {
         $lastPath = dirname($lastPath);
         if ($filesystem->exists($lastPath . DIRECTORY_SEPARATOR . 'composer.json') || $filesystem->exists($lastPath . DIRECTORY_SEPARATOR . 'composer.json')) {
             return $lastPath;
         }
     }
     throw new \RuntimeException('Could not find project root');
 }
开发者ID:xtain,项目名称:environment-detector,代码行数:16,代码来源:Project.php

示例11: resolve

 /**
  * @param Method $method
  * @return array
  */
 public function resolve(Method $method)
 {
     /** @var Annotation $annotation */
     $annotation = $method->annotations->withName('Template')->first();
     // テンプレート名を取得する
     $name = array_shift($annotation->parameters);
     if (!$name) {
         $templateReference = $this->guessTemplateName($method->class->getFQCN(), str_replace('Action', '', $method->name));
     } else {
         $templateReference = $this->templateNameParser->parse($this->kernel->getRootDir() . '/Resources/views/' . $name);
     }
     $template = $this->loader->load($templateReference);
     return ['method' => $method, 'name' => $name, 'template' => $templateReference, 'path' => $template];
 }
开发者ID:hidenorigoto,项目名称:annotation-checker-bundle,代码行数:18,代码来源:TemplateAnnotationResolver.php

示例12: getResources

 /**
  * Returns an array of translation files for a given domain and a given locale.
  *
  * @param string $domainName    A domain translation name.
  * @param string $locale        A locale.
  * @return array                An array of translation files.
  */
 public function getResources($domainName, $locale)
 {
     $finder = new Finder();
     $locations = array();
     foreach ($this->kernel->getBundles() as $bundle) {
         if (is_dir($bundle->getPath() . '/Resources/translations')) {
             $locations[] = $bundle->getPath() . '/Resources/translations';
         }
     }
     if (is_dir($this->kernel->getRootDir() . '/Resources/translations')) {
         $locations[] = $this->kernel->getRootDir() . '/Resources/translations';
     }
     return $finder->files()->name($domainName . '.' . $locale . '.*')->followLinks()->in($locations);
 }
开发者ID:nvdnkpr,项目名称:BazingaExposeTranslationBundle,代码行数:21,代码来源:TranslationFinder.php

示例13: registerCommandsToApplication

 /**
  * @return Application
  */
 private function registerCommandsToApplication(Application $application, KernelInterface $kernel)
 {
     chdir($kernel->getRootDir() . '/..');
     foreach ($this->getBundlesFromKernel($kernel) as $bundle) {
         $bundle->registerCommands($application);
     }
     return $application;
 }
开发者ID:raphydev,项目名称:onep,代码行数:11,代码来源:ApplicationFactory.php

示例14: loadCommonFixtures

 /**
  * Load common fixtures
  *
  * @param KernelInterface $kernel Kernel
  *
  * @return $this Self object
  */
 private function loadCommonFixtures(KernelInterface $kernel)
 {
     $rootDir = $kernel->getRootDir();
     $command = 'doctrine:fixtures:load ' . '--fixtures=' . $rootDir . '/../src/Elcodi/Plugin/ ' . '--fixtures=' . $rootDir . '/../src/Elcodi/Fixtures ' . '--env=test ' . '--no-interaction ' . '--quiet ';
     $input = new StringInput($command);
     $this->application->run($input);
     return $this;
 }
开发者ID:axelvnk,项目名称:bamboo,代码行数:15,代码来源:EnvironmentBuilder.php

示例15: getCmd

 /**
  * get subcommand
  *
  * @param array $args args
  *
  * @return string
  */
 private function getCmd(array $args)
 {
     // get path to console from kernel..
     $consolePath = $this->kernel->getRootDir() . '/console';
     $cmd = 'php ' . $consolePath . ' -n ';
     foreach ($args as $key => $val) {
         if (strlen($key) > 1) {
             $cmd .= ' ' . $key;
         }
         if (strlen($key) > 1 && !is_null($val)) {
             $cmd .= '=';
         }
         if (strlen($val) > 1) {
             $cmd .= escapeshellarg($val);
         }
     }
     return $cmd;
 }
开发者ID:alebon,项目名称:graviton,代码行数:25,代码来源:CommandRunner.php


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