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


PHP Filesystem::makePathRelative方法代码示例

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


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

示例1: publish

 /**
  * @param string $targetPath
  * @param string $installPath
  * @param array $map
  * @param bool $isSymlink
  * @param bool $isRelative
  *
  * @throws IOException
  * @throws \InvalidArgumentException
  *
  * @api
  *
  * @quality:method [B]
  */
 public function publish($targetPath, $installPath, array $map, $isSymlink, $isRelative)
 {
     $targetPath = rtrim($targetPath, '/');
     $installPath = rtrim($installPath, '/');
     $this->filesystem->mkdir($targetPath, 0777);
     foreach ($map as $from => $to) {
         $targetDir = realpath($targetPath) . '/' . $to;
         $sourceDir = realpath($installPath) . '/' . $from;
         $this->filesystem->remove($targetDir);
         if ($isSymlink) {
             $this->io->write(sprintf('Trying to install AdminLTE %s assets as symbolic links.', $from));
             $originDir = $sourceDir;
             if ($isRelative) {
                 $originDir = $this->filesystem->makePathRelative($sourceDir, realpath($targetPath));
             }
             try {
                 $this->filesystem->symlink($originDir, $targetDir);
                 $this->io->write(sprintf('The AdminLTE %s assets were installed using symbolic links.', $from));
             } catch (IOException $e) {
                 $this->hardCopy($sourceDir, $targetDir);
                 $this->io->write(sprintf('It looks like your system doesn\'t support symbolic links,
                     so the AdminLTE %s assets were installed by copying them.', $from));
             }
         } else {
             $this->io->write(sprintf('Installing AdminLTE %s assets as <comment>hard copies</comment>.', $from));
             $this->hardCopy($sourceDir, $targetDir);
         }
     }
 }
开发者ID:kamilsk,项目名称:common,代码行数:43,代码来源:Processor.php

示例2: symlinkPackageToVendor

 private function symlinkPackageToVendor($packagePath, $vendorPath)
 {
     $relative = $this->fileSystem->makePathRelative(realpath($packagePath), realpath($vendorPath . '/../'));
     $this->fileSystem->rename($vendorPath, $vendorPath . '_linked', true);
     $this->fileSystem->symlink($relative, $vendorPath);
     $this->fileSystem->remove($vendorPath . '_linked');
 }
开发者ID:mybuilder,项目名称:conductor,代码行数:7,代码来源:Conductor.php

示例3: getScribiteEditorHelpers

 /**
  * Adds extra JS to load on pages using the Scribite editor.
  *
  * @param Zikula_Event $event
  */
 public function getScribiteEditorHelpers(Zikula_Event $event)
 {
     // intended is using the add() method to add a helper like below
     $helpers = $event->getSubject();
     $helpers->add(['module' => 'CmfcmfMediaModule', 'type' => 'javascript', 'path' => $this->fs->makePathRelative($this->resourceRoot . '/public/js/vendor', $this->zikulaRoot) . 'toastr.min.js']);
     $helpers->add(['module' => 'CmfcmfMediaModule', 'type' => 'stylesheet', 'path' => $this->fs->makePathRelative($this->resourceRoot . '/public/css/vendor', $this->zikulaRoot) . 'toastr.min.css']);
     $helpers->add(['module' => 'CmfcmfMediaModule', 'type' => 'javascript', 'path' => $this->fs->makePathRelative($this->resourceRoot . '/public/js', $this->zikulaRoot) . 'util.js']);
 }
开发者ID:shefik,项目名称:MediaModule,代码行数:13,代码来源:ThirdPartyListener.php

示例4: createConfig

 /**
  * @param string $src
  *
  * @return Configuration
  */
 private function createConfig($src)
 {
     $configuration = new Configuration($src);
     $configuration->setJsonFile('component.json');
     $configuration->setEndpoint('https://bower.herokuapp.com');
     $configuration->setCache(new FilesystemCache($this->target . '/cache'));
     $configuration->setAssetDirectory($this->filesystem->makePathRelative($this->target . '/components', $src));
     return $configuration;
 }
开发者ID:boskee,项目名称:SpBowerBundle,代码行数:14,代码来源:BowerFunctionalTest.php

示例5: __construct

 public function __construct(TranslatorInterface $translator, $kernelCacheDir, $kernelRootDir)
 {
     $this->fs = new Filesystem();
     $this->cacheFile = $kernelCacheDir . "/CmfcmfMediaModule.zip";
     $zikulaDir = realpath($kernelRootDir . '/..');
     $this->moduleDir = $this->fs->makePathRelative(realpath(__DIR__ . '/..'), $zikulaDir);
     $this->domain = \ZLanguage::getModuleDomain('CmfcmfMediaModule');
     $this->translator = $translator;
 }
开发者ID:shefik,项目名称:MediaModule,代码行数:9,代码来源:ModuleUpgrader.php

示例6: getCompilationOptions

 protected function getCompilationOptions()
 {
     $fs = new Filesystem();
     $fs->mkdir(dirname($this->getBootstrapLessFile()));
     $assets_dir = $fs->makePathRelative(realpath($this->getAssetsDir()), realpath(dirname($this->getBootstrapLessFile())));
     $variablesDir = $fs->makePathRelative(realpath(dirname($this->getVariablesFile())), realpath(dirname($this->getBootstrapLessFile())));
     $variablesFile = sprintf('%s%s', $variablesDir, basename($this->getVariablesFile()));
     return array('variables_dir' => $variablesDir, 'variables_file' => $variablesFile, 'assets_dir' => $assets_dir);
 }
开发者ID:scaytrase,项目名称:symfony-switchable-theme,代码行数:9,代码来源:AbstractBootstrapTheme.php

示例7: show

 /**
  * @param Bundle  $bundle
  * @param string  $type
  * @param boolean $regenerate
  *
  * @return string
  */
 public function show(Bundle $bundle, $type = 'long', $regenerate = false)
 {
     $relativePath = $this->filesystem->makePathRelative($this->cacheDir, $this->rootDir);
     $filename = sprintf('%sbadges/%s/%s-%s.png', $relativePath, $type, $bundle->getOwnerName(), $bundle->getName());
     if (false !== $regenerate || !$this->filesystem->exists($filename)) {
         $this->generate($bundle);
     }
     return $filename;
 }
开发者ID:KnpLabs,项目名称:KnpBundles,代码行数:16,代码来源:BadgeGenerator.php

示例8: symlink

 private function symlink($target, $link)
 {
     // echo __LINE__, "\n", $target, " ==> " , $link, "\n" ;
     if (!file_exists($target)) {
         throw new \Exception(sprintf("`%s` is not exists", $target));
     }
     if (is_link($link)) {
         $_target = readlink($link);
         if (realpath($_target) != realpath($target)) {
             // throw new \Exception( sprintf("`%s` should be a link point to `%s`, but it point to `%s`",  $link , $target, $_target ) ) ;
             unlink($link);
         } else {
             return;
         }
     } else {
         if (file_exists($link)) {
             throw new \Exception(sprintf("`%s` should be a link point to `%s`", $link, $target));
         }
     }
     $_path = $this->file_system->makePathRelative($target, dirname($link));
     $_path = rtrim($_path, '/');
     symlink($_path, $link);
     if (!file_exists($link)) {
         throw new \Exception(sprintf("`%s` is not exists, link to `%s` -> `%s`", $link, $_path, $target));
     }
 }
开发者ID:symforce,项目名称:symforce-admin,代码行数:26,代码来源:SetupCommand.php

示例9: prepareDrupalRoot

 /**
  * Links Drupal core, modules, themes and assets into Drupal root.
  *
  * @param Event $event
  */
 public static function prepareDrupalRoot(Event $event)
 {
     $options = self::getOptions($event);
     $composer = $event->getComposer();
     $filesystem = new Filesystem();
     $originDir = realpath($composer->getConfig()->get('vendor-dir') . '/drupal/drupal');
     $targetDir = realpath($options['drupal-root']);
     if (is_dir($originDir)) {
         if ($options['drupal-install']['relative']) {
             $originDir = rtrim($filesystem->makePathRelative($originDir, $targetDir), '/');
         }
         $directories = array('includes', 'misc', 'modules', 'themes');
         foreach ($directories as $directory) {
             $filesystem->remove($targetDir . '/' . $directory);
             if ($options['drupal-install']['symlink']) {
                 $event->getIO()->write(sprintf('Creating symlink for Drupal\'s \'%s\' directory', $directory));
                 $filesystem->symlink($originDir . '/' . $directory, $targetDir . '/' . $directory);
             } else {
                 $event->getIO()->write(sprintf('Copying Drupal\'s \'%s\' directory to web root', $directory));
                 $filesystem->mkdir($targetDir . '/' . $directory, 0777);
                 // We use a custom iterator to ignore VCS files
                 $filesystem->mirror($originDir . '/' . $directory, $targetDir . '/' . $directory, Finder::create()->ignoreDotFiles(false)->in($originDir));
             }
         }
     }
 }
开发者ID:bangpound,项目名称:drupal-bridge,代码行数:31,代码来源:ScriptHandler.php

示例10: installPluginAssets

 /**
  * @param $dir
  * @param  InputInterface  $input
  * @param  OutputInterface $output
  * @return bool
  */
 private function installPluginAssets($dir, InputInterface $input, OutputInterface $output)
 {
     // Create the specific assets directory otherwise symlink will fail.
     $assetsDir = $dir . '/assets/plugins/';
     $this->filesystem->mkdir($assetsDir, 0777);
     $plugins = $this->getContainer()->get('simplr.pluginmanager')->getActivePlugins();
     if (!empty($plugins)) {
         foreach ($plugins as $name => $configuration) {
             $activePluginPath = $this->getContainer()->get('simplr.pluginmanager')->getPathToPlugin($name);
             if (is_dir($originDir = $activePluginPath . '/Resources/public')) {
                 $targetDir = $assetsDir . strtolower($name);
                 $output->writeln(sprintf("Installing assets for plugin <comment>%s</comment> into <comment>%s</comment>", $name, $targetDir));
                 $this->filesystem->remove($targetDir);
                 if ($input->getOption('symlink')) {
                     if ($input->getOption('relative')) {
                         $relativeOriginDir = $this->filesystem->makePathRelative($originDir, realpath($assetsDir));
                     } else {
                         $relativeOriginDir = $originDir;
                     }
                     $this->filesystem->symlink($relativeOriginDir, $targetDir);
                 } else {
                     $this->filesystem->mkdir($targetDir, 0777);
                     // We use a custom iterator to ignore VCS files
                     $this->filesystem->mirror($originDir, $targetDir, Finder::create()->in($originDir));
                 }
             }
         }
     } else {
         $output->writeln('Installing assets for plugins... no plugins found!');
     }
     return true;
 }
开发者ID:cleentfaar,项目名称:simplr-core,代码行数:38,代码来源:SimplrAssetsInstallCommand.php

示例11: bbs_twig_template

 public function bbs_twig_template(\Twig_Environment $env, $file, $path, $templateid = 0)
 {
     /**
      * @var $loader \Symfony\Bundle\TwigBundle\Loader\FilesystemLoader
      */
     $loader = $env->getLoader();
     $tplfile = $loader->getCacheKey($file);
     if (null === $this->file_system) {
         $this->file_system = new \Symfony\Component\Filesystem\Filesystem();
     }
     $tplfile = rtrim($this->file_system->makePathRelative($tplfile, DISCUZ_ROOT), '/');
     if (empty($path) || !is_string($path)) {
         throw new \Exception(sprintf("path(%s) must be string", json_encode($path)));
     }
     $this->cache['app_template_cache_file'] = './data/template/' . (defined('STYLEID') ? STYLEID . '_' : '_') . $templateid . '_' . preg_replace('/\\W/', '_', $file) . '.tpl.php';
     $tpldir = './template/default';
     $_pos = strpos($path, ':');
     if (false !== $_pos) {
         if ($_pos !== strrpos($path, ':')) {
             throw new \Exception(sprintf('not implement locate plugin tempalte dir:%s', $path));
         }
         $tpldir = sprintf('./source/plugin/%s/template', substr($path, 0, $_pos));
     }
     checktplrefresh($tplfile, $tplfile, @filemtime(DISCUZ_ROOT . $this->cache['app_template_cache_file']), $templateid, $this->cache['app_template_cache_file'], $tpldir, $path);
     unset($tplfile, $tpldir, $loader, $env, $path, $templateid, $_pos);
     extract($GLOBALS, EXTR_REFS);
     include DISCUZ_ROOT . $this->cache['app_template_cache_file'];
 }
开发者ID:symforce,项目名称:symforce-discuz,代码行数:28,代码来源:SymforceDiscuzTwigExtension.php

示例12: initializeLocalRepository

 /**
  * @return GitRepository
  */
 protected function initializeLocalRepository()
 {
     $cloneUrl = $this->filesystem->makePathRelative(self::REMOTE_REPOSITORY_DIRECTORY, dirname(self::LOCAL_REPOSITORY_DIRECTORY));
     $localRepository = new GitRepository($this->gitWrapper, self::LOCAL_REPOSITORY_DIRECTORY);
     $localRepository->create($cloneUrl);
     return $localRepository;
 }
开发者ID:ichhabrecht,项目名称:git-wrapper,代码行数:10,代码来源:GitRepositoryTest.php

示例13: levelUp

 /**
  * Get relative path.
  *
  * @param string $namespace
  *
  * @return string
  */
 public function levelUp($namespace)
 {
     if (empty($namespace)) {
         return '';
     } else {
         return $this->fs->makePathRelative($this->outputDir, $this->getPathByNamespace($namespace, true));
     }
 }
开发者ID:komex,项目名称:unteist,代码行数:15,代码来源:TwigReport.php

示例14: printExceptionTrace

 /**
  * Prints trace / call stack / backtrace of an exception.
  *
  * @param  array  $trace The back trace to print out.
  */
 private function printExceptionTrace(array $trace)
 {
     $trace = array_reverse($trace);
     $this->output->writeln('Call Stack:');
     foreach ($trace as $i => $call) {
         $this->output->writeln(sprintf('    %d. <info>%s%s%s(</info>%s<info>)</info> in <comment>%s</comment>:%d', $i + 1, $call['class'], $call['type'], $call['function'], $this->parseCallArguments($call['args']), $this->filesystem->makePathRelative($call['file'], $this->cwd), $call['line']));
     }
 }
开发者ID:splot,项目名称:framework,代码行数:13,代码来源:ConsoleErrorHandler.php

示例15: testCacheDirLocation

 /**
  * Checks if giving a relative path results in the same path under water.
  */
 public function testCacheDirLocation()
 {
     $cacheDirLocation = $this->cache->getDirectory();
     $filesystem = new Filesystem();
     $relative = $filesystem->makePathRelative($cacheDirLocation, __DIR__);
     $newCache = new Cache($relative);
     $this->assertEquals($cacheDirLocation, $newCache->getDirectory());
 }
开发者ID:Hoplite-Software,项目名称:observatory,代码行数:11,代码来源:CacheTest.php


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