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


PHP Path::makeAbsolute方法代码示例

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


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

示例1: generateNewInstance

 /**
  * {@inheritdoc}
  */
 public function generateNewInstance($varName, Method $targetMethod, GeneratorRegistry $generatorRegistry, array $options = array())
 {
     Assert::keyExists($options, 'root-dir', 'The "root-dir" option is missing.');
     $options = array_replace_recursive(self::$defaultOptions, $options);
     if (!isset($options['path'])) {
         $options['path'] = $targetMethod->getClass()->getDirectory() . '/path-mappings.json';
     }
     Assert::stringNotEmpty($options['path'], 'The "path" option should be a non-empty string. Got: %s');
     Assert::stringNotEmpty($options['root-dir'], 'The "root-dir" option should be a non-empty string. Got: %s');
     Assert::boolean($options['optimize'], 'The "optimize" option should be a boolean. Got: %s');
     Assert::isArray($options['change-stream'], 'The "change-stream" option should be an array. Got: %s');
     $path = Path::makeAbsolute($options['path'], $options['root-dir']);
     $relPath = Path::makeRelative($path, $targetMethod->getClass()->getDirectory());
     $relBaseDir = Path::makeRelative($options['root-dir'], $targetMethod->getClass()->getDirectory());
     $escPath = '__DIR__.' . var_export('/' . $relPath, true);
     $escBaseDir = $relBaseDir ? '__DIR__.' . var_export('/' . $relBaseDir, true) : '__DIR__';
     if ($options['optimize']) {
         $streamGenerator = $generatorRegistry->getServiceGenerator(GeneratorRegistry::CHANGE_STREAM, $options['change-stream']['type']);
         $streamOptions = $options['change-stream'];
         $streamOptions['root-dir'] = $options['root-dir'];
         $streamGenerator->generateNewInstance('stream', $targetMethod, $generatorRegistry, $streamOptions);
         $targetMethod->getClass()->addImport(new Import('Puli\\Repository\\OptimizedJsonRepository'));
         $targetMethod->addBody(sprintf('$%s = new OptimizedJsonRepository(%s, %s, false, $stream);', $varName, $escPath, $escBaseDir));
     } else {
         $targetMethod->getClass()->addImport(new Import('Puli\\Repository\\JsonRepository'));
         $targetMethod->addBody(sprintf('$%s = new JsonRepository(%s, %s, true);', $varName, $escPath, $escBaseDir));
     }
 }
开发者ID:xabbuh,项目名称:manager,代码行数:31,代码来源:JsonRepositoryGenerator.php

示例2: installResource

 /**
  * {@inheritdoc}
  */
 public function installResource(Resource $resource, InstallationParams $params)
 {
     $targetPath = Path::makeAbsolute($params->getTargetLocation(), $params->getRootDirectory());
     if (!file_exists($targetPath)) {
         mkdir($targetPath, 0777, true);
     }
     $repoPath = $params->getWebPathForResource($resource);
     $parameterValues = $params->getParameterValues();
     $relative = !isset($parameterValues['relative']) || $parameterValues['relative'];
     $filesystemRepo = new FilesystemRepository($targetPath, $this->symlinks, $relative);
     if ('/' === $repoPath) {
         foreach ($resource->listChildren() as $child) {
             $name = $child->getName();
             // If the resource is not attached, the name is empty
             if (!$name && $child instanceof FilesystemResource) {
                 $name = Path::getFilename($child->getFilesystemPath());
             }
             if ($name) {
                 $filesystemRepo->remove($repoPath . '/' . $name);
             }
         }
     } else {
         $filesystemRepo->remove($repoPath);
     }
     $filesystemRepo->add($repoPath, $resource);
 }
开发者ID:puli,项目名称:asset-plugin,代码行数:29,代码来源:CopyInstaller.php

示例3: generateNewInstance

    /**
     * {@inheritdoc}
     */
    public function generateNewInstance($varName, Method $targetMethod, GeneratorRegistry $generatorRegistry, array $options = array())
    {
        Assert::keyExists($options, 'rootDir', 'The "rootDir" option is missing.');
        $options = array_replace(self::$defaultOptions, $options);
        if (!isset($options['path'])) {
            $options['path'] = $targetMethod->getClass()->getDirectory() . '/repository';
        }
        Assert::string($options['path'], 'The "path" option should be a string. Got: %s');
        Assert::string($options['rootDir'], 'The "rootDir" option should be a string. Got: %s');
        Assert::boolean($options['symlink'], 'The "symlink" option should be a boolean. Got: %s');
        $path = Path::makeAbsolute($options['path'], $options['rootDir']);
        $relPath = Path::makeRelative($path, $targetMethod->getClass()->getDirectory());
        $escPath = $relPath ? '__DIR__.' . var_export('/' . $relPath, true) : '__DIR__';
        if ($relPath) {
            $targetMethod->addBody(<<<EOF
if (!file_exists({$escPath})) {
    mkdir({$escPath}, 0777, true);
}

EOF
);
        }
        $targetMethod->getClass()->addImport(new Import('Puli\\Repository\\FilesystemRepository'));
        $targetMethod->addBody(sprintf('$%s = new FilesystemRepository(%s, %s);', $varName, $escPath, var_export($options['symlink'], true)));
    }
开发者ID:niklongstone,项目名称:manager,代码行数:28,代码来源:FilesystemRepositoryGenerator.php

示例4: installResource

 /**
  * {@inheritdoc}
  */
 public function installResource(PuliResource $resource, InstallationParams $params)
 {
     $documentRoot = Path::makeAbsolute($params->getDocumentRoot(), $params->getRootDirectory());
     if (!file_exists($documentRoot)) {
         mkdir($documentRoot, 0777, true);
     }
     $serverPath = $params->getServerPathForResource($resource);
     $parameterValues = $params->getParameterValues();
     $relative = !isset($parameterValues['relative']) || $parameterValues['relative'];
     $filesystemRepo = new FilesystemRepository($documentRoot, $this->symlinks, $relative);
     if ('/' === $serverPath) {
         foreach ($resource->listChildren() as $child) {
             $name = $child->getName();
             // If the resource is not attached, the name is empty
             if (!$name && $child instanceof FilesystemResource) {
                 $name = Path::getFilename($child->getFilesystemPath());
             }
             if ($name) {
                 $filesystemRepo->remove($serverPath . '/' . $name);
             }
         }
     } else {
         $filesystemRepo->remove($serverPath);
     }
     // Don't attach the original resource to the repository we just created
     $filesystemRepo->add($serverPath, clone $resource);
 }
开发者ID:xabbuh,项目名称:manager,代码行数:30,代码来源:CopyInstaller.php

示例5: generateNewInstance

 /**
  * {@inheritdoc}
  */
 public function generateNewInstance($varName, Method $targetMethod, GeneratorRegistry $generatorRegistry, array $options = array())
 {
     Assert::keyExists($options, 'root-dir', 'The "root-dir" option is missing.');
     $options = array_replace(self::$defaultOptions, $options);
     Assert::stringNotEmpty($options['path'], 'The "path" option should be a non-empty string. Got: %s');
     Assert::stringNotEmpty($options['root-dir'], 'The "root-dir" option should be a non-empty string. Got: %s');
     Assert::boolean($options['serialize-strings'], 'The "serialize-strings" option should be a boolean. Got: %s');
     Assert::boolean($options['serialize-arrays'], 'The "serialize-arrays" option should be a boolean. Got: %s');
     Assert::boolean($options['escape-slash'], 'The "escape-slash" option should be a boolean. Got: %s');
     Assert::boolean($options['pretty-print'], 'The "pretty-print" option should be a boolean. Got: %s');
     $path = Path::makeAbsolute($options['path'], $options['root-dir']);
     $relPath = Path::makeRelative($path, $targetMethod->getClass()->getDirectory());
     $flags = array();
     if (!$options['serialize-strings']) {
         $flags[] = 'JsonFileStore::NO_SERIALIZE_STRINGS';
     }
     if (!$options['serialize-arrays']) {
         $flags[] = 'JsonFileStore::NO_SERIALIZE_ARRAYS';
     }
     if (!$options['serialize-arrays']) {
         $flags[] = 'JsonFileStore::NO_ESCAPE_SLASH';
     }
     if ($options['pretty-print']) {
         $flags[] = 'JsonFileStore::PRETTY_PRINT';
     }
     $targetMethod->getClass()->addImport(new Import('Webmozart\\KeyValueStore\\JsonFileStore'));
     $targetMethod->addBody(sprintf('$%s = new JsonFileStore(%s%s%s);', $varName, $flags ? "\n    " : '', '__DIR__.' . var_export('/' . $relPath, true), $flags ? ",\n    " . implode("\n        | ", $flags) . "\n" : ''));
 }
开发者ID:xabbuh,项目名称:manager,代码行数:31,代码来源:JsonFileStoreGenerator.php

示例6: handleAdd

 /**
  * Handles the "package --add" command.
  *
  * @param Args $args The console arguments.
  *
  * @return int The status code.
  */
 public function handleAdd(Args $args)
 {
     $packageName = $args->getArgument('name');
     $installPath = Path::makeAbsolute($args->getArgument('path'), getcwd());
     $installer = $args->getOption('installer');
     $this->packageManager->installPackage($installPath, $packageName, $installer);
     return 0;
 }
开发者ID:rejinka,项目名称:cli,代码行数:15,代码来源:PackageCommandHandler.php

示例7: makeConfigPathRelative

 /**
  * Concat two path member only if the second is not absolute
  * and make the result relative to the last parameter.
  */
 public static function makeConfigPathRelative($config_path, $option_path, $current_path = null)
 {
     $current_path = $current_path === null ? getcwd() : $current_path;
     $config_path = Path::makeAbsolute($config_path, $current_path);
     $absolute_path = Path::makeAbsolute($option_path, $config_path);
     $relative_path = Path::makeRelative($absolute_path, $current_path);
     return $relative_path === '' ? '.' : $relative_path;
 }
开发者ID:inetprocess,项目名称:sugarcli,代码行数:12,代码来源:Utils.php

示例8: handleInstall

 /**
  * Handles the "package --install" command.
  *
  * @param Args $args The console arguments.
  *
  * @return int The status code.
  */
 public function handleInstall(Args $args)
 {
     $packageName = $args->getArgument('name');
     $installPath = Path::makeAbsolute($args->getArgument('path'), getcwd());
     $installer = $args->getOption('installer');
     $env = $args->isOptionSet('dev') ? Environment::DEV : Environment::PROD;
     $this->packageManager->installPackage($installPath, $packageName, $installer, $env);
     return 0;
 }
开发者ID:webmozart,项目名称:cli,代码行数:16,代码来源:PackageCommandHandler.php

示例9: generateNewInstance

 /**
  * {@inheritdoc}
  */
 public function generateNewInstance($varName, Method $targetMethod, GeneratorRegistry $generatorRegistry, array $options = array())
 {
     Assert::keyExists($options, 'rootDir', 'The "rootDir" option is missing.');
     $options = array_replace(self::$defaultOptions, $options);
     $path = Path::makeAbsolute($options['path'], $options['rootDir']);
     $relPath = Path::makeRelative($path, $targetMethod->getClass()->getDirectory());
     $targetMethod->getClass()->addImport(new Import('Webmozart\\KeyValueStore\\JsonFileStore'));
     $targetMethod->addBody(sprintf('$%s = new JsonFileStore(%s, %s);', $varName, '__DIR__.' . var_export('/' . $relPath, true), $options['cache'] ? 'true' : 'false'));
 }
开发者ID:niklongstone,项目名称:manager,代码行数:12,代码来源:JsonFileStoreGenerator.php

示例10: analyse

 /**
  * @param string $path
  * @param string|null $configFile
  * @param AbstractLogger $logger
  * @return Result
  */
 public function analyse($path, $configFile = null, AbstractLogger $logger = null)
 {
     $logger = $logger ?: new NullLogger();
     $path = Path::makeAbsolute($path, getcwd());
     if (!$configFile) {
         $configFile = Path::join([$path, '.simpspector.yml']);
     }
     $config = $this->loader->load($configFile);
     return $this->executor->run($path, $config, $logger);
 }
开发者ID:simpspector,项目名称:analyser,代码行数:16,代码来源:Analyser.php

示例11: handle

 /**
  * Handles the "tree" command.
  *
  * @param Args $args The console arguments.
  * @param IO   $io   The I/O.
  *
  * @return int The status code.
  */
 public function handle(Args $args, IO $io)
 {
     $path = Path::makeAbsolute($args->getArgument('path'), $this->currentPath);
     $resource = $this->repo->get($path);
     $total = 0;
     $io->writeLine('<c1>' . $resource->getPath() . '</c1>');
     $this->printTree($io, $resource, $total);
     $io->writeLine('');
     $io->writeLine($total . ' resources');
     return 0;
 }
开发者ID:msojda,项目名称:cli,代码行数:19,代码来源:TreeCommandHandler.php

示例12: retrieve

 /**
  * {@inheritdoc}
  */
 public function retrieve($uri)
 {
     if (isset($this->mappings[$uri])) {
         $uri = $this->mappings[$uri];
         if (Path::isLocal($uri)) {
             $uri = 'file://' . ($this->baseDir ? Path::makeAbsolute($uri, $this->baseDir) : $uri);
         }
         $this->lastUsedRetriever = $this->filesystemRetriever;
         return $this->filesystemRetriever->retrieve($uri);
     }
     $this->lastUsedRetriever = $this->fallbackRetriever;
     return $this->fallbackRetriever->retrieve($uri);
 }
开发者ID:webmozart,项目名称:json,代码行数:16,代码来源:LocalUriRetriever.php

示例13: handle

 /**
  * Handles the "ls" command.
  *
  * @param Args $args The console arguments.
  * @param IO   $io   The I/O.
  *
  * @return int The status code.
  */
 public function handle(Args $args, IO $io)
 {
     $path = Path::makeAbsolute($args->getArgument('path'), $this->currentPath);
     $resource = $this->repo->get($path);
     if (!$resource->hasChildren()) {
         throw new RuntimeException(sprintf('The resource "%s" does not have children.', $resource->getPath()));
     }
     if ($args->isOptionSet('long')) {
         $this->listLong($io, $resource->listChildren());
     } else {
         $this->listShort($io, $resource->listChildren());
     }
     return 0;
 }
开发者ID:rejinka,项目名称:cli,代码行数:22,代码来源:LsCommandHandler.php

示例14: generateNewInstance

 /**
  * {@inheritdoc}
  */
 public function generateNewInstance($varName, Method $targetMethod, GeneratorRegistry $generatorRegistry, array $options = array())
 {
     Assert::keyExists($options, 'root-dir', 'The "root-dir" option is missing.');
     if (!isset($options['path'])) {
         $options['path'] = $targetMethod->getClass()->getDirectory() . '/change-stream.json';
     }
     Assert::stringNotEmpty($options['root-dir'], 'The "root-dir" option should be a non-empty string. Got: %s');
     Assert::stringNotEmpty($options['path'], 'The "path" option should be a non-empty string. Got: %s');
     $path = Path::makeAbsolute($options['path'], $options['root-dir']);
     $relPath = Path::makeRelative($path, $targetMethod->getClass()->getDirectory());
     $escPath = '__DIR__.' . var_export('/' . $relPath, true);
     $targetMethod->getClass()->addImport(new Import('Puli\\Repository\\ChangeStream\\JsonChangeStream'));
     $targetMethod->addBody(sprintf('$%s = new JsonChangeStream(%s);', $varName, $escPath));
 }
开发者ID:xabbuh,项目名称:manager,代码行数:17,代码来源:JsonChangeStreamGenerator.php

示例15: handle

 /**
  * Handles the "ls" command.
  *
  * @param Args $args The console arguments.
  * @param IO   $io   The I/O.
  *
  * @return int The status code.
  */
 public function handle(Args $args, IO $io)
 {
     $path = Path::makeAbsolute($args->getArgument('path'), $this->currentPath);
     $resources = $this->repo->find($path);
     if (!count($resources)) {
         $io->errorLine("No resources found for path {$path}");
         return 1;
     }
     foreach ($resources as $resource) {
         if ($resource instanceof BodyResource) {
             $io->writeLine($resource->getBody());
         }
     }
     return 0;
 }
开发者ID:holloway87,项目名称:cli,代码行数:23,代码来源:CatCommandHandler.php


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