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


PHP Kernel::getRootDir方法代码示例

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


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

示例1: generatePdfFile

 /**
  * Generate PDF-file of ticket
  *
  * @param string $html       HTML to generate pdf
  * @param string $outputFile Name of output file
  *
  * @return mixed
  */
 public function generatePdfFile($html, $outputFile)
 {
     // Override default fonts directory for mPDF
     define('_MPDF_SYSTEM_TTFONTS', realpath($this->kernel->getRootDir() . '/../web/fonts/open-sans/') . '/');
     /** @var \TFox\MpdfPortBundle\Service\MpdfService $mPDFService */
     $mPDFService = $this->container->get('tfox.mpdfport');
     $mPDFService->setAddDefaultConstructorArgs(false);
     $constructorArgs = array('mode' => 'BLANK', 'format' => 'A5-L', 'margin_left' => 0, 'margin_right' => 0, 'margin_top' => 0, 'margin_bottom' => 0, 'margin_header' => 0, 'margin_footer' => 0);
     $mPDF = $mPDFService->getMpdf($constructorArgs);
     // Open Sans font settings
     $mPDF->fontdata['opensans'] = array('R' => 'OpenSans-Regular.ttf', 'B' => 'OpenSans-Bold.ttf', 'I' => 'OpenSans-Italic.ttf', 'BI' => 'OpenSans-BoldItalic.ttf');
     $mPDF->sans_fonts[] = 'opensans';
     $mPDF->available_unifonts[] = 'opensans';
     $mPDF->available_unifonts[] = 'opensansI';
     $mPDF->available_unifonts[] = 'opensansB';
     $mPDF->available_unifonts[] = 'opensansBI';
     $mPDF->default_available_fonts[] = 'opensans';
     $mPDF->default_available_fonts[] = 'opensansI';
     $mPDF->default_available_fonts[] = 'opensansB';
     $mPDF->default_available_fonts[] = 'opensansBI';
     $mPDF->SetDisplayMode('fullpage');
     $mPDF->WriteHTML($html);
     $pdfFile = $mPDF->Output($outputFile, 'S');
     return $pdfFile;
 }
开发者ID:jekakm,项目名称:fwdays,代码行数:33,代码来源:PdfGeneratorHelper.php

示例2: resolvePath

 private function resolvePath($file)
 {
     if (isset($this->config['aliases'][$file]['path'])) {
         return $this->kernel->getRootDir() . '/../web/' . $this->config['aliases'][$file]['path'];
     }
     return $file;
 }
开发者ID:burdanews,项目名称:twig-extensions-bundle,代码行数:7,代码来源:ResponsiveSvgExtension.php

示例3: getClassName

 public function getClassName($path)
 {
     $srcDir = realpath(sprintf('%s/../src', $this->kernel->getRootDir()));
     $className = substr($path, strlen($srcDir) + 1);
     $className = str_replace('/', '\\', $className);
     $className = str_replace('.php', '', $className);
     return $className;
 }
开发者ID:enhavo,项目名称:enhavo,代码行数:8,代码来源:ExtendFormTypeGenerator.php

示例4: authenticate

 /**
  * @param string $filePath
  * @param \Symfony\Component\HttpFoundation\ServerBag $server
  *
  * @return bool
  */
 private function authenticate($filePath, ServerBag $server)
 {
     $passFile = $this->kernel->getRootDir() . '/../web/var/export/' . substr($filePath, 0, strrpos($filePath, '/')) . '/.htpasswd';
     list($auth['user'], $auth['pass']) = explode(':', file_get_contents($passFile));
     $user = $server->get('PHP_AUTH_USER');
     $pass = crypt($server->get('PHP_AUTH_PW'), md5($server->get('PHP_AUTH_PW')));
     return $user == $auth['user'] && $pass == $auth['pass'];
 }
开发者ID:kamilmusial,项目名称:EzSystemsRecommendationBundle,代码行数:14,代码来源:ExportController.php

示例5: getResource

 /**
  * @param $filename
  * @return array
  */
 public function getResource($filename)
 {
     $builder = new PathBuilder($this->resourcesDir);
     $fullPath = $builder->getResourcesPath($this->kernel->getRootDir(), $filename);
     $role = $builder->getRoleFromPath($fullPath);
     if ($role != null && false === $this->securityContext->isGranted($role)) {
         throw new AccessDeniedException();
     }
     if (!file_exists($fullPath)) {
         throw new FileNotFoundException(sprintf("The file %s was not found", $filename));
     }
     $contentType = MimeType::get($filename);
     return ['contentType' => $contentType, 'content' => file_get_contents($fullPath)];
 }
开发者ID:NathanVss,项目名称:resources-firewall-bundle,代码行数:18,代码来源:Firewall.php

示例6: loadScripts

 /**
  * Read scripts info from files
  */
 protected function loadScripts()
 {
     $index = 0;
     $scripts = [];
     $this->scripts = [];
     $rootDir = realpath($this->kernel->getRootDir() . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR);
     $bundles = $this->kernel->getBundles();
     foreach ($bundles as $bundle) {
         $bundleDirName = $bundle->getPath();
         $this->getScriptInfo($bundleDirName, $index, $scripts);
         $relativePathArray = explode(DIRECTORY_SEPARATOR, str_replace($rootDir, '', $bundleDirName));
         if ($relativePathArray[0] == '') {
             unset($relativePathArray[0]);
         }
         for ($i = count($relativePathArray); $i >= 0; $i--) {
             unset($relativePathArray[$i]);
             $checkPath = $rootDir . DIRECTORY_SEPARATOR . implode(DIRECTORY_SEPARATOR, $relativePathArray);
             if ($this->getScriptInfo($checkPath, $index, $scripts)) {
                 break;
             }
         }
     }
     if (!empty($scripts)) {
         usort($scripts, array($this, "compareScripts"));
         foreach ($scripts as $script) {
             $this->scripts[$script['key']] = $script;
         }
     }
 }
开发者ID:omaoibrahim,项目名称:chamilo-lms,代码行数:32,代码来源:ScriptManager.php

示例7: getRootDir

 /**
  * Override check for Kernel Root Dir.
  * Otherwise, the app will misbehave on Heroku.
  *
  * @return mixed|string
  */
 public function getRootDir()
 {
     if (Utils\HerokuDetector::detected()) {
         return Utils\HerokuDetector::getSymfonyKernelRoot();
     } else {
         return parent::getRootDir();
     }
 }
开发者ID:ck99,项目名称:heroku-bundle,代码行数:14,代码来源:AppKernel.php

示例8: buildRequest

 /**
  * Builds a new request object based on the given route.
  *
  * @param Route  $route      Route.
  * @param string $name       Name of the route.
  * @param array  $parameters Parameters of the request
  *
  * @return Request
  */
 protected function buildRequest(Route $route, $name = null, array $parameters = array())
 {
     if (null !== $name) {
         $uri = $this->router->generate($name, $parameters);
     } else {
         $uri = $route->getPath();
     }
     return new Request([], [], [], [], [], ['REQUEST_URI' => $uri, 'DOCUMENT_URI' => $uri, 'SCRIPT_FILENAME' => realpath($this->kernel->getRootDir() . '/../web') . $this->baseUrl . '/app.php', 'SCRIPT_NAME' => $this->baseUrl . '/app.php'], null);
 }
开发者ID:braincrafted,项目名称:static-site-bundle,代码行数:18,代码来源:RouteRenderer.php

示例9: setCiPaths

 /**
  * Initialize CodeIgniter system paths and defines
  *
  * @param Request $request
  *
  * @throws \UnexpectedValueException
  */
 public function setCiPaths(Request $request = null)
 {
     if (!$this->isConfigValid()) {
         throw new \UnexpectedValueException('Bundle configuration is not valid. You need to specify application_path and system_path in config.yml');
     }
     if ($this->pathsInitialized === false) {
         $scriptFile = $request !== null ? '.' . $request->getBasePath() . $request->getScriptName() : __FILE__;
         $rootPath = realpath($this->kernel->getRootDir() . '/..');
         if ($rootPath === false) {
             throw new \LogicException('Nercury CI bundle was expecting to find kernel root dir in /app directory.');
         }
         $systemPath = $this->getSystemPath() . '/';
         $applicationFolder = $this->getAppPath() . '/';
         if ($scriptFile === __FILE__) {
             $scriptFile = $rootPath . '/app.php';
             $rootPath = realpath($rootPath . '/' . $systemPath) . '/';
             $applicationFolder = realpath($rootPath . '/' . $applicationFolder);
         }
         $environment = $this->kernel->getEnvironment();
         $environmentMap = array('dev' => 'development', 'test' => 'testing', 'prod' => 'production');
         if (array_key_exists($environment, $environmentMap)) {
             $environment = $environmentMap[$environment];
         }
         define('ENVIRONMENT', $environment);
         /*
          * -------------------------------------------------------------------
          *  Now that we know the path, set the main path constants
          * -------------------------------------------------------------------
          */
         // The name of THIS file
         define('SELF', pathinfo($scriptFile, PATHINFO_BASENAME));
         // The PHP file extension
         // this global constant is deprecated.
         define('EXT', '.php');
         // Path to the system folder
         define('BASEPATH', str_replace("\\", "/", $systemPath));
         // Name of the "system folder"
         define('SYSDIR', trim(strrchr(trim(BASEPATH, '/'), '/'), '/'));
         define('APPPATH', $applicationFolder . '/');
         // Path to the front controller (this file)
         define('FCPATH', $applicationFolder . '../');
         //            if (!defined('APPPATH')) {
         //                // The path to the "application" folder
         //                if (is_dir($application_folder)) {
         //                    define('APPPATH', $application_folder . '/');
         //                } else {
         //                    if (!is_dir(BASEPATH . $application_folder . '/')) {
         //                        exit("Your application folder path does not appear to be set correctly. Please open the following file and correct this: " . SELF);
         //                    }
         //
         //                    define('APPPATH', BASEPATH . $application_folder . '/');
         //                }
         //            }
         $this->pathsInitialized = true;
     }
 }
开发者ID:BahuL,项目名称:NercuryCodeIgniterBundle,代码行数:63,代码来源:CiHelperService.php

示例10: generateHTML

 /**
  * Create HTML template for ticket invitation
  *
  * @param Ticket $ticket
  *
  * @return string
  */
 public function generateHTML(Ticket $ticket)
 {
     $twig = $this->templating;
     $url = $this->router->generate('event_ticket_registration', array('ticket' => $ticket->getId(), 'hash' => $ticket->getHash()), true);
     $this->qrCode->setText($url);
     $this->qrCode->setSize(105);
     $this->qrCode->setPadding(0);
     $qrCodeBase64 = base64_encode($this->qrCode->get());
     $templateContent = $twig->loadTemplate('StfalconEventBundle:Ticket:_pdf.html.twig');
     $body = $templateContent->render(array('ticket' => $ticket, 'qrCodeBase64' => $qrCodeBase64, 'path' => realpath($this->kernel->getRootDir() . '/../web') . '/'));
     return $body;
 }
开发者ID:bolotyuh,项目名称:fwdays,代码行数:19,代码来源:PdfGeneratorHelper.php

示例11: downloadExternalImage

 /**
  * @param string $format ImBundle format string
  * @param string $path   cached path for an external image - ex: http/somepath/somefile.jpg or https/somepath/someotherfile.jpg
  *
  * The cached path is equivalent to the original path except that the '://' syntax after the protocol is replaced by a simple "/", to conserve a correct URL encoded string
  * The Twig tag 'imResize' will automatically make this conversion for you
  *
  * @return string
  */
 public function downloadExternalImage($format, $path)
 {
     $protocol = substr($path, 0, strpos($path, "/"));
     $newPath = str_replace($protocol . "/", $this->kernel->getRootDir() . '/../web/cache/im/' . $format . '/' . $protocol . '/', $path);
     $this->wrapper->checkDirectory($newPath);
     $fp = fopen($newPath, 'w');
     $ch = curl_init(str_replace($protocol . '/', $protocol . '://', $path));
     curl_setopt($ch, CURLOPT_FILE, $fp);
     curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
     curl_setopt($ch, CURLOPT_HEADER, 0);
     curl_exec($ch);
     curl_close($ch);
     fclose($fp);
     return $newPath;
 }
开发者ID:nacmartin,项目名称:SnowcapImBundle,代码行数:24,代码来源:Manager.php

示例12: setCiPaths

 /**
  * Initialize code igniter system paths and defines
  * 
  * @param Request $request
  * @throws Exception 
  */
 public function setCiPaths(Request $request = null)
 {
     if (!$this->isConfigValid()) {
         throw new \Exception('Code Igniter configuration is not valid.');
     }
     if ($this->paths_initalized === false) {
         $script_file = $request !== null ? '.' . $request->getBasePath() . $request->getScriptName() : __FILE__;
         $root_path = realpath($this->kernel->getRootDir() . '/..');
         if ($root_path === false) {
             throw new \LogicException('Nercury CI bundle was expecting to find kernel root dir in /app directory.');
         }
         $system_path = $this->getRelativePath($root_path, $this->getSystemPath()) . '/';
         $application_folder = $this->getRelativePath($root_path, $this->getAppPath());
         if ($script_file === __FILE__) {
             $script_file = $root_path . '/app.php';
             $system_path = realpath($root_path . '/' . $system_path) . '/';
             $application_folder = realpath($root_path . '/' . $application_folder);
         }
         /*
          * -------------------------------------------------------------------
          *  Now that we know the path, set the main path constants
          * -------------------------------------------------------------------
          */
         // The name of THIS file
         define('SELF', pathinfo($script_file, PATHINFO_BASENAME));
         // The PHP file extension
         // this global constant is deprecated.
         define('EXT', '.php');
         // Path to the system folder
         define('BASEPATH', str_replace("\\", "/", $system_path));
         // Path to the front controller (this file)
         define('FCPATH', str_replace(SELF, '', __FILE__));
         // Name of the "system folder"
         define('SYSDIR', trim(strrchr(trim(BASEPATH, '/'), '/'), '/'));
         // The path to the "application" folder
         if (is_dir($application_folder)) {
             define('APPPATH', $application_folder . '/');
         } else {
             if (!is_dir(BASEPATH . $application_folder . '/')) {
                 exit("Your application folder path does not appear to be set correctly. Please open the following file and correct this: " . SELF);
             }
             define('APPPATH', BASEPATH . $application_folder . '/');
         }
         $this->paths_initalized = true;
     }
 }
开发者ID:rocktopus,项目名称:NercuryCodeIgniterBundle,代码行数:52,代码来源:CiHelperService.php

示例13: parseCSV

 private function parseCSV($ignoreFirstLine)
 {
     $finder = new Finder();
     $finder->files()->in($this->kernel->getRootDir() . '/../')->name('*Fundraising.csv');
     foreach ($finder as $file) {
         $csv = $file;
     }
     $this->output('Load CSV: ' . $csv->getRealPath());
     $rows = array();
     if (($handle = fopen($csv->getRealPath(), "r")) !== FALSE) {
         $i = 0;
         while (($data = fgetcsv($handle, null, ";")) !== FALSE) {
             $i++;
             if ($ignoreFirstLine && $i == 1) {
                 continue;
             }
             $rows[] = $data;
         }
         fclose($handle);
     }
     return $rows;
 }
开发者ID:nuffer,项目名称:FundraisingDB,代码行数:22,代码来源:LoadCommand.php

示例14: updateJsLib

 /**
  * @return string
  */
 public function updateJsLib()
 {
     $response = $this->kernel->handle(Request::create('/js/fp_js_validator.js'));
     $libFile = $this->kernel->getRootDir() . '/../../Resources/public/js/fp_js_validator.js';
     file_put_contents($libFile, $response->getContent());
 }
开发者ID:eko,项目名称:JsFormValidatorBundle,代码行数:9,代码来源:TestTwigExtension.php

示例15: __construct

 /**
  * @param Kernel $kernel
  */
 public function __construct(Kernel $kernel)
 {
     $this->webDir = $kernel->getRootDir() . '/../web';
 }
开发者ID:ChrisdAutume,项目名称:EtuUTT,代码行数:7,代码来源:BodyParser.php


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