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


PHP Path::getFilename方法代码示例

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


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

示例1: 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

示例2: 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

示例3: testGetFilenameFailsIfInvalidPath

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

示例4: filesAutoComplete

 /**
  * Return autocomplete data for a file name.
  *
  * @param Request $request
  *
  * @return \Symfony\Component\HttpFoundation\JsonResponse
  */
 public function filesAutoComplete(Request $request)
 {
     $term = $request->query->get('term', '.*');
     $dir = Path::getDirectory($term);
     $term = Path::getFilename($term);
     $term = preg_quote($term);
     $extensions = implode('|', explode(',', $request->query->get('ext', '.*')));
     $regex = sprintf('/.*(%s).*\\.(%s)$/', $term, $extensions);
     $files = $this->filesystem()->find()->in('files://' . $dir)->name($regex);
     $result = [];
     /** @var \Bolt\Filesystem\Handler\File $file */
     foreach ($files as $file) {
         $result[] = $file->toJs();
     }
     return $this->json($result);
 }
开发者ID:bolt,项目名称:bolt,代码行数:23,代码来源:FilesystemManager.php

示例5: setFilePath

 /**
  * Sets the absolute file path of the factory class file.
  *
  * @param string $filePath The absolute file path.
  *
  * @return static The current instance.
  */
 public function setFilePath($filePath)
 {
     Assert::stringNotEmpty($filePath, 'The factory file path must be a non-empty string. Got: %s');
     $this->setDirectory(Path::getDirectory($filePath));
     $this->setFileName(Path::getFilename($filePath));
     return $this;
 }
开发者ID:niklongstone,项目名称:manager,代码行数:14,代码来源:Clazz.php


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