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


PHP Kernel::locateResource方法代码示例

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


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

示例1: getFilters

 public function getFilters()
 {
     $client = new \Mleko\ImageSqueeze\Client\Client();
     $squeeze = new \Twig_SimpleFilter('squeeze', function ($path) use($client) {
         $path = (string) $path;
         if (strlen($path) > 0 && $path[0] === '@') {
             $path = $this->kernel->locateResource($path);
         }
         if (file_exists($path)) {
             $inputFile = new \Mleko\ImageSqueeze\Client\File($path);
         } else {
             $inputFile = new \Mleko\ImageSqueeze\Client\File($path, $this->webRoot);
         }
         $pathHash = str_pad(base_convert(sha1($path), 16, 36), 31, '0', STR_PAD_LEFT);
         $compressedName = implode("/", str_split(substr($pathHash, 0, 6), 1)) . "/" . substr($pathHash, 6);
         if (false !== ($dotPosition = strrpos($path, "."))) {
             $compressedName .= substr($path, $dotPosition);
         }
         $newPath = '/cache/image/' . $compressedName;
         $fullPath = $this->webRoot . $newPath;
         if (!file_exists($fullPath)) {
             $newDir = dirname($fullPath);
             if (!file_exists($newDir)) {
                 mkdir($newDir, 0777, true);
             }
             return $client->shrink($inputFile)->toFile($newPath, $this->webRoot);
         }
         return new \Mleko\ImageSqueeze\Client\File($newPath, $this->webRoot);
     });
     return ['squeeze' => $squeeze];
 }
开发者ID:mleko,项目名称:image-squeeze-bundle,代码行数:31,代码来源:ImageSqueezeExtension.php

示例2: copyTemplates

 protected function copyTemplates()
 {
     $from = $this->kernel->locateResource('@AnimeDbCatalogBundle/Resources/views/');
     $to = $this->root_dir . '/Resources/';
     // overwrite twig error templates
     $this->fs->copy($from . 'errors/error.html.twig', $to . 'TwigBundle/views/Exception/error.html.twig', true);
     $this->fs->copy($from . 'errors/error404.html.twig', $to . 'TwigBundle/views/Exception/error404.html.twig', true);
 }
开发者ID:anime-db,项目名称:catalog-bundle,代码行数:8,代码来源:Package.php

示例3: resolveTargetFormType

 public function resolveTargetFormType($name)
 {
     $parts = preg_split('/:/', $name);
     $bundleName = $parts[0];
     $formType = $parts[1];
     $bundlePath = $this->kernel->locateResource(sprintf('@%s', $bundleName));
     $path = sprintf('%sForm/Type/%sType.php', $bundlePath, $formType);
     return $path;
 }
开发者ID:enhavo,项目名称:enhavo,代码行数:9,代码来源:ExtendFormTypeGenerator.php

示例4: resolve

 protected function resolve($groups, $input)
 {
     $resolved = array();
     if (strpos($input, '@') === false) {
         return array($this->webdir . '/' . $input);
     }
     $cleaned = str_replace('@', '', $input);
     if (isset($groups[$cleaned])) {
         foreach ($groups[$cleaned]['inputs'] as $candidate) {
             $resolved = array_merge($resolved, $this->resolve($groups, $candidate));
         }
         return $resolved;
     }
     if (($star = strpos($input, '*')) === false) {
         return array($this->kernel->locateResource($input));
     } else {
         $dir = $this->kernel->locateResource(substr($input, 0, $star));
         $it = new \DirectoryIterator($dir);
         foreach ($it as $file) {
             if ($file->isFile()) {
                 array_push($resolved, $it->getRealPath());
             }
         }
     }
     return $resolved;
 }
开发者ID:pladodev,项目名称:AdminThemeBundle,代码行数:26,代码来源:BuildAssetsCommand.php

示例5: let

 public function let(IntentDocumentGeneratedEvent $event, RumGeneratorInterface $rumGenerator, Intent $intent, Kernel $kernel)
 {
     $this->event = $event;
     $this->rumGenerator = $rumGenerator;
     $this->intent = $intent;
     $this->kernel = $kernel;
     $this->event->getIntent()->willReturn($this->intent);
     $kernel->locateResource('@DonatePaymentBundle/Resources/public/img/sepa-template.jpg')->willReturn(__DIR__ . '/test.jpg');
     $this->beConstructedWith($rumGenerator, $kernel);
 }
开发者ID:bco-trey,项目名称:edonate,代码行数:10,代码来源:GenerateSepaPdfListenerSpec.php

示例6: __construct

 /**
  * Construct the manager
  *
  * @param Kernel $kernel
  * @param string $path
  * @param string $maskBuilder
  */
 public function __construct(Kernel $kernel, $path, $maskBuilder)
 {
     $this->maskBuilder = $maskBuilder;
     $path = $kernel->locateResource('@' . $path);
     $config = Yaml::parse($path);
     $this->config = $config['acl_config'];
     $replace = array();
     if (isset($config['parameters'])) {
         foreach ($config['parameters'] as $k => $v) {
             $replace['%' . $k . '%'] = $v;
         }
         $this->config = $this->replaceParameters($this->config, $replace);
     }
     return $this->config;
 }
开发者ID:apfz,项目名称:ACLInterfaceBundle,代码行数:22,代码来源:ConfigManager.php

示例7: locateResource

 public function locateResource($name, $dir = null, $first = true)
 {
     if (substr($name, 0, 4) == '@Kwc') {
         if (!$first) {
             throw new \Kwf_Exception_NotYetImplemented();
         }
         $componentClass = substr($name, 4, strpos($name, '/') - 4);
         $name = substr($name, strpos($name, '/') + 1);
         $paths = \Kwc_Abstract::getSetting($componentClass, 'parentFilePaths');
         foreach ($paths as $path => $cls) {
             if (file_exists($path . '/' . $name)) {
                 return $path . '/' . $name;
             }
         }
         throw new \Kwf_Exception();
     } else {
         return parent::locateResource($name, $dir, $first);
     }
 }
开发者ID:koala-framework,项目名称:koala-framework,代码行数:19,代码来源:SymfonyKernel.php

示例8: uploadfile

 /**
  * Returns an UploadedFile based on a source file
  * @param  string $source 
  * @return UploadedFile
  */
 public function uploadfile($source)
 {
     $source = $this->kernel->locateResource($source);
     return new UploadedFile($source, basename($source));
 }
开发者ID:studiocaramia,项目名称:redking_CoreRestBundle,代码行数:10,代码来源:Media.php

示例9: locateResource

 /**
  * @param string $name
  * @param string $dir
  * @param bool $first
  * @return string|array
  */
 public function locateResource($name, $dir = null, $first = true)
 {
     return $this->kernel->locateResource($name, $dir, $first);
 }
开发者ID:integratedfordevelopers,项目名称:integrated-theme-bundle,代码行数:10,代码来源:ThemeManager.php

示例10: locateResource

 /**
  * {@inheritdoc}
  *
  * @throws \RuntimeException if a custom resource is hidden by a resource in a derived bundle
  */
 public function locateResource($name, $dir = null, $first = true)
 {
     $themeBundle = $this->container->get('zikula_core.common.theme_engine')->getTheme();
     $locations = parent::locateResource($name, $dir, false);
     if ($locations && false !== strpos($locations[0], $dir)) {
         // if found in $dir (typically app/Resources) return it immediately.
         return $locations[0];
     }
     // add theme path to template locator
     // this method functions if the controller uses `@Template` or `ZikulaSpecModule:Foo:index.html.twig` naming scheme
     // if `@ZikulaSpecModule/Foo/index.html.twig` (name-spaced) naming scheme is used
     // the \Zikula\Bundle\CoreBundle\EventListener\ThemeListener::setUpThemePathOverrides method is used instead
     if ($themeBundle && false === strpos($name, $themeBundle->getName())) {
         // do not add theme override path to theme files
         $customThemePath = $themeBundle->getPath() . '/Resources';
         return parent::locateResource($name, $customThemePath, true);
     }
     return $locations[0];
 }
开发者ID:Silwereth,项目名称:core,代码行数:24,代码来源:ZikulaKernel.php


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