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


PHP Path::isAbsolute方法代码示例

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


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

示例1: load

 /**
  * {@inheritdoc}
  *
  * @throws \InvalidArgumentException
  * @throws \RuntimeException
  * @throws \LogicException
  * @throws BadMethodCallException
  */
 public function load($resource, $type = null)
 {
     $path = $this->locator->locate($resource);
     $this->container->addResource(new FileResource($path));
     $file = new JsonFile($path);
     $content = $file->read();
     $extension = pathinfo($resource, PATHINFO_FILENAME);
     if (array_key_exists('parameters', $content)) {
         foreach ($content['parameters'] as $name => $parameter) {
             $this->container->setParameter($name, $parameter);
         }
         unset($content['parameters']);
     }
     if (array_key_exists('imports', $content)) {
         foreach ($content['imports'] as $import) {
             $importFilename = $import;
             if (!Path::isAbsolute($importFilename)) {
                 $importFilename = Path::join([dirname($path), $import]);
             }
             $this->import($importFilename, null, false, $file);
         }
         unset($content['imports']);
     }
     $this->container->loadFromExtension($extension, $content);
 }
开发者ID:nanbando,项目名称:core,代码行数:33,代码来源:JsonLoader.php

示例2: __construct

 /**
  * Constructor.
  *
  * @param string $pattern
  * @param string $uriPattern
  */
 public function __construct($pattern, $uriPattern = '/**/*')
 {
     if (!Path::isAbsolute($pattern)) {
         $pattern = Path::join(getcwd(), $pattern);
     }
     $this->pattern = $pattern;
     $this->uriPattern = $uriPattern;
 }
开发者ID:oscarotero,项目名称:statico,代码行数:14,代码来源:Source.php

示例3: filterReferences

 public static function filterReferences($content, $callback)
 {
     return CssUtils::filterReferences($content, function ($matches) use($callback) {
         // The referenced path is a repository path
         // e.g. "/webmozart/puli/images/bg.png"
         $referencedPath = $matches['url'];
         // Ignore empty URLs
         if ('' === $referencedPath) {
             return $matches[0];
         }
         // Ignore non-local paths
         if (!Path::isLocal($referencedPath)) {
             return $matches[0];
         }
         // Ignore "data:" URLs
         if (0 === strpos($referencedPath, 'data:')) {
             return $matches[0];
         }
         // If the referenced path is not absolute, resolve it relative to
         // the directory of the source file
         if (!Path::isAbsolute($referencedPath)) {
             $referencedPath = Path::makeAbsolute($referencedPath, $repoDir);
         }
         // The referenced asset must be known
         if (!array_key_exists($referencedPath, $pathMap)) {
             throw new AssetException(sprintf('The asset "%s" referenced in "%s" could not be found.', $matches['url'], $repoPath));
         }
         // The target path of the referenced file must be set
         if (!$pathMap[$referencedPath]) {
             throw new AssetException(sprintf('The referenced path "%s" in "%s" cannot be resolved, because ' . 'the target path of "%s" is not set.', $matches['url'], $repoPath, $matches['url']));
         }
         // The target path of the source file must be set
         if (!$targetPath) {
             throw new AssetException(sprintf('The referenced path "%s" in "%s" cannot be resolved, because ' . 'the target path of "%s" is not set.', $matches['url'], $repoPath, $repoPath));
         }
         // Get the relative path from the source directory to the reference
         // e.g. "/css/style.css" + "/images/bg.png" = "../images/bg.png"
         $relativePath = Path::makeRelative($pathMap[$referencedPath], $targetDir);
         return str_replace($matches['url'], $relativePath, $matches[0]);
     });
 }
开发者ID:puli,项目名称:assetic-extension,代码行数:41,代码来源:PuliCssUtils.php

示例4: encodeFile

 private function encodeFile($jsonData, $path)
 {
     if (!is_string($path) || !Path::isAbsolute($path)) {
         throw new IOException(sprintf('Cannot write "%s": Expected an absolute path.', $path));
     }
     if (is_dir($path)) {
         throw new IOException(sprintf('Cannot write %s: Is a directory.', $path));
     }
     $encoder = new JsonEncoder();
     $encoder->setPrettyPrinting(true);
     $encoder->setEscapeSlash(false);
     $encoder->setTerminateWithLineFeed(true);
     $decoder = new JsonDecoder();
     // We can't use realpath(), which doesn't work inside PHARs.
     // However, we want to display nice paths if the file is not found.
     $schema = $decoder->decodeFile(Path::canonicalize(__DIR__ . '/../../res/schema/package-schema-1.0.json'));
     $configSchema = $schema->properties->config;
     if (!is_dir($dir = Path::getDirectory($path))) {
         $filesystem = new Filesystem();
         $filesystem->mkdir($dir);
     }
     $encoder->encodeFile($jsonData, $path, $configSchema);
 }
开发者ID:niklongstone,项目名称:manager,代码行数:23,代码来源:ConfigJsonWriter.php

示例5: extractTargetPaths

 private function extractTargetPaths(AssetInterface $asset, &$array)
 {
     if ($asset instanceof PuliAsset) {
         $targetPath = $asset->getTargetPath();
         // All relative paths are treated like absolute paths
         // Don't change empty paths so that we can throw an exception
         // later
         if ($targetPath && !Path::isAbsolute($targetPath)) {
             $targetPath = '/' . $targetPath;
         }
         $array[$asset->getSourcePath()] = $targetPath;
     } elseif ($asset instanceof AssetCollection) {
         foreach ($asset as $entry) {
             $this->extractTargetPaths($entry, $array);
         }
     }
 }
开发者ID:puli,项目名称:assetic-extension,代码行数:17,代码来源:PuliCssRewriteFilter.php

示例6: absoluteSystemPath

 public static function absoluteSystemPath($value)
 {
     self::stringNotEmpty($value, 'The path must be a non-empty string. Got: %s');
     self::true(Path::isAbsolute($value), sprintf('The path %s is not absolute.', $value));
 }
开发者ID:niklongstone,项目名称:manager,代码行数:5,代码来源:Assert.php

示例7: testIsAbsoluteFailsIfInvalidPath

 /**
  * @expectedException \InvalidArgumentException
  * @expectedExceptionMessage The path must be a string. Got: array
  */
 public function testIsAbsoluteFailsIfInvalidPath()
 {
     Path::isAbsolute(array());
 }
开发者ID:webmozart,项目名称:path-util,代码行数:8,代码来源:PathTest.php

示例8: targetLinksToSource

 /**
  * Check if target is linked and links to the given source.
  *
  * @return bool
  */
 public function targetLinksToSource()
 {
     if (!$this->targetIsLink()) {
         return FALSE;
     }
     $current_source = readlink($this->link);
     if (!Path::isAbsolute($current_source)) {
         $current_source = Path::makeAbsolute($current_source, dirname($this->link));
     }
     return $current_source == $this->source;
 }
开发者ID:derhasi,项目名称:symlinker,代码行数:16,代码来源:Symlink.php

示例9: getStaticPrefix

 /**
  * Returns the static prefix of a glob.
  *
  * The "static prefix" is the part of the glob up to the first wildcard "*".
  * If the glob does not contain wildcards, the full glob is returned.
  *
  * @param string $glob  The canonical glob. The glob should contain forward
  *                      slashes as directory separators only. It must not
  *                      contain any "." or ".." segments. Use the
  *                      "webmozart/path-util" utility to canonicalize globs
  *                      prior to calling this method.
  * @param int    $flags A bitwise combination of the flag constants in this
  *                      class.
  *
  * @return string The static prefix of the glob.
  */
 public static function getStaticPrefix($glob, $flags = 0)
 {
     if (!Path::isAbsolute($glob) && false === strpos($glob, '://')) {
         throw new InvalidArgumentException(sprintf('The glob "%s" is not absolute and not a URI.', $glob));
     }
     $prefix = $glob;
     if ($flags & self::ESCAPE) {
         // Read backslashes together with the next (the escaped) character
         // up to the first non-escaped star/brace
         if (preg_match('~^(' . Symbol::BACKSLASH . '.|[^' . Symbol::BACKSLASH . Symbol::STAR . Symbol::L_BRACE . '])*~', $glob, $matches)) {
             $prefix = $matches[0];
         }
         // Replace escaped characters by their unescaped equivalents
         $prefix = str_replace(array('\\\\', '\\*', '\\{', '\\}'), array('\\', '*', '{', '}'), $prefix);
     } else {
         $pos1 = strpos($glob, '*');
         $pos2 = strpos($glob, '{');
         if (false !== $pos1 && false !== $pos2) {
             $prefix = substr($glob, 0, min($pos1, $pos2));
         } elseif (false !== $pos1) {
             $prefix = substr($glob, 0, $pos1);
         } elseif (false !== $pos2) {
             $prefix = substr($glob, 0, $pos2);
         }
     }
     return $prefix;
 }
开发者ID:akochnov,项目名称:fts,代码行数:43,代码来源:Glob.php

示例10: canonicalize

 /**
  * @param string $basePath
  * @param string $path
  *
  * @return string
  */
 private function canonicalize($basePath, $path)
 {
     return Path::canonicalize(Path::isAbsolute($path) ? $path : sprintf('%s/%s', $basePath, $path));
 }
开发者ID:phn-io,项目名称:dal,代码行数:10,代码来源:Parser.php

示例11: getStaticPrefix

 /**
  * Returns the static prefix of a glob.
  *
  * The "static prefix" is the part of the glob up to the first wildcard "*".
  * If the glob does not contain wildcards, the full glob is returned.
  *
  * @param string $glob  The canonical glob. The glob should contain forward
  *                      slashes as directory separators only. It must not
  *                      contain any "." or ".." segments. Use the
  *                      "webmozart/path-util" utility to canonicalize globs
  *                      prior to calling this method.
  * @param int    $flags A bitwise combination of the flag constants in this
  *                      class.
  *
  * @return string The static prefix of the glob.
  */
 public static function getStaticPrefix($glob, $flags = 0)
 {
     if (!Path::isAbsolute($glob) && false === strpos($glob, '://')) {
         throw new InvalidArgumentException(sprintf('The glob "%s" is not absolute and not a URI.', $glob));
     }
     $prefix = '';
     $length = strlen($glob);
     for ($i = 0; $i < $length; ++$i) {
         $c = $glob[$i];
         switch ($c) {
             case '/':
                 $prefix .= '/';
                 if (isset($glob[$i + 3]) && '**/' === $glob[$i + 1] . $glob[$i + 2] . $glob[$i + 3]) {
                     break 2;
                 }
                 break;
             case '*':
             case '?':
             case '{':
             case '[':
                 break 2;
             case '\\':
                 if (isset($glob[$i + 1])) {
                     switch ($glob[$i + 1]) {
                         case '*':
                         case '?':
                         case '{':
                         case '[':
                         case '\\':
                             $prefix .= $glob[$i + 1];
                             ++$i;
                             break;
                         default:
                             $prefix .= '\\';
                     }
                 } else {
                     $prefix .= '\\';
                 }
                 break;
             default:
                 $prefix .= $c;
                 break;
         }
     }
     return $prefix;
 }
开发者ID:webmozart,项目名称:glob,代码行数:62,代码来源:Glob.php

示例12: parseInputWithFixedValues

 /**
  * Converts an input to an asset using the given variable values.
  *
  * An "input" in Assetic's terminology is a reference string to an asset,
  * such as "css/*.css", "/webmozart/puli/style.css",
  * "@AcmeDemoBundle/Resources/css/style.css" etc.
  *
  * Contrary to {@link parseInput()}, this method converts an input to an
  * asset that contains variables and whose variable values are already
  * known. For example, if the input is "js/messages.{locale}.js" with the
  * variable "locale" and its value "en", an asset is created for the input
  * "js/messages.en.js" using the resolution logic described in
  * {@link PuliAssetFactory}.
  *
  * @param string      $input      An input string containing variables.
  * @param string|null $currentDir The Puli directory of the currently loaded
  *                                Twig template. This is `null` if the
  *                                template was not loaded through Puli.
  * @param string[]    $roots      The file system root directories to search
  *                                for relative inputs.
  * @param string[]    $vars       The variables that may occur in the input.
  * @param string[]    $values     A mapping of variable names to values.
  *
  * @return AssetInterface The created asset.
  *
  * @see parseInput()
  */
 public function parseInputWithFixedValues($input, $currentDir, array $roots = array(), array $vars = array(), array $values = array())
 {
     if (Path::isAbsolute($input)) {
         return $this->parseAbsoluteInput($input, $roots, $vars, $values);
     }
     return $this->parseRelativeInput($input, $currentDir, $roots, $vars, $values);
 }
开发者ID:puli,项目名称:assetic-extension,代码行数:34,代码来源:PuliAssetFactory.php


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