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


PHP SplFileInfo::getBasename方法代码示例

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


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

示例1: getBundleClass

 /**
  * Returns FQCN for file
  *
  * @param SplFileInfo $fileInfo
  *
  * @return string|null
  */
 private function getBundleClass(SplFileInfo $fileInfo)
 {
     $reflection = new ReflectionFile($fileInfo->getRealPath());
     $baseName = $fileInfo->getBasename('.php');
     foreach ($reflection->getNamespaces() as $namespace) {
         return $namespace . '\\' . $baseName;
     }
     return null;
 }
开发者ID:WellCommerce,项目名称:DistributionBundle,代码行数:16,代码来源:BundleLocator.php

示例2: __construct

 public function __construct(SplFileInfo $file)
 {
     $this->file = $file;
     $this->path = str_replace('\\', '/', $file->getRelativePath());
     $this->filename = $file->getFilename();
     $this->package = $file->getBasename('.zip');
     $this->version = 'dev-unknown';
     list($this->type, $this->vendor) = explode('/', $this->path);
     $matches = $this->parseFilename($this->filename);
     if (!empty($matches)) {
         $this->package = $matches['package'];
         $this->version = $matches['version'];
     }
 }
开发者ID:rarst,项目名称:release-belt,代码行数:14,代码来源:Release.php

示例3: addFile

 /**
  * Add a file into the phar package.
  *
  * @param Phar        $phar  Phar object
  * @param SplFileInfo $file  File to add
  * @param bool        $strip strip
  *
  * @return Compiler self Object
  */
 protected function addFile(Phar $phar, SplFileInfo $file, $strip = true)
 {
     $path = strtr(str_replace(dirname(dirname(dirname(__DIR__))) . DIRECTORY_SEPARATOR, '', $file->getRealPath()), '\\', '/');
     $content = $file->getContents();
     if ($strip) {
         $content = $this->stripWhitespace($content);
     } elseif ('LICENSE' === $file->getBasename()) {
         $content = "\n" . $content . "\n";
     }
     if ($path === 'src/Composer/Composer.php') {
         $content = str_replace('@package_version@', $this->version, $content);
         $content = str_replace('@release_date@', $this->versionDate, $content);
     }
     $phar->addFromString($path, $content);
     return $this;
 }
开发者ID:mmoreram,项目名称:php-formatter,代码行数:25,代码来源:Compiler.php

示例4: loadGeneratorInBundle

 /**
  * Load a single generator into the registry.
  * @param SplFileInfo $file
  * @param string      $ns
  */
 private function loadGeneratorInBundle(SplFileInfo $file, $ns)
 {
     if ($relativePath = $file->getRelativePath()) {
         $ns .= '\\' . strtr($relativePath, '/', '\\');
     }
     $class = $ns . '\\' . $file->getBasename('.php');
     // if an alias of the generator exists, skip this one
     if ($this->container) {
         $alias = 'tweedegolf_generator.generator.' . strtolower(str_replace('\\', '_', $class));
         if ($this->container->has($alias)) {
             return;
         }
     }
     // add the generator through reflection
     $r = new \ReflectionClass($class);
     if ($r->isSubclassOf('TweedeGolf\\Generator\\GeneratorInterface') && !$r->isAbstract() && !$r->getConstructor()->getNumberOfRequiredParameters()) {
         $this->addGenerator($r->newInstance());
     }
 }
开发者ID:tweedegolf,项目名称:generatorbundle,代码行数:24,代码来源:SymfonyGeneratorRegistry.php

示例5: __construct

 /**
  * Constructor.
  *
  * @param null|SplFileInfo $file
  */
 public function __construct(SplFileInfo $file = null)
 {
     $this->file = $file;
     if ($this->file instanceof SplFileInfo) {
         // file extension: "md"
         $this->fileExtension = pathinfo($this->file, PATHINFO_EXTENSION);
         // file path: "Blog"
         $this->filePath = str_replace(DIRECTORY_SEPARATOR, '/', $this->file->getRelativePath());
         // file id: "Blog/Post 1"
         $this->fileId = ($this->filePath ? $this->filePath . '/' : '') . basename($this->file->getBasename(), '.' . $this->fileExtension);
         /*
          * variables default values
          */
         // id - ie: "blog/post-1"
         $this->id = $this->urlize($this->fileId);
         // pathname - ie: "blog/post-1"
         $this->pathname = $this->urlize($this->fileId);
         // path - ie: "blog"
         $this->path = $this->urlize($this->filePath);
         // name - ie: "post-1"
         $this->name = $this->urlize(basename($this->file->getBasename(), '.' . $this->fileExtension));
         /*
          * front matter default values
          */
         // title - ie: "Post 1"
         $this->setTitle(basename($this->file->getBasename(), '.' . $this->fileExtension));
         // section - ie: "blog"
         $this->setSection(explode('/', $this->path)[0]);
         // date
         $this->setDate(filemtime($this->file->getPathname()));
         // permalink
         $this->setPermalink($this->pathname);
         parent::__construct($this->id);
     } else {
         $this->virtual = true;
         parent::__construct();
     }
 }
开发者ID:narno,项目名称:phpoole-library,代码行数:43,代码来源:Page.php

示例6: getQualifiedName

 /**
  * @param \Symfony\Component\Finder\SplFileInfo $fileInfo
  * @return string
  */
 protected function getQualifiedName(SplFileInfo $fileInfo)
 {
     if (!preg_match('/namespace (.+?);/', $fileInfo->getContents(), $match)) {
         return null;
     }
     return $match[1] . '\\' . $fileInfo->getBasename('.php');
 }
开发者ID:eXolnet,项目名称:laravel-console,代码行数:11,代码来源:FillModel.php

示例7: getFilename

 /**
  * Returns filename w/o extension
  *
  * @return string
  */
 public function getFilename()
 {
     $exclude = '.' . $this->file->getExtension();
     return $this->file->getBasename($exclude);
 }
开发者ID:jtallant,项目名称:skimpy-engine,代码行数:10,代码来源:ContentFile.php

示例8: getClassname

 /**
  * Gets the class name.
  *
  * @param \Symfony\Component\Finder\SplFileInfo $file
  *
  * @return string
  */
 protected function getClassname(SplFileInfo $file)
 {
     if ($file->getExtension() === 'php') {
         return $file->getBasename('.php');
     }
     if ($file->getFilename() === $this->composerFilename) {
         $composerData = $this->readComposerFile($file);
         if (isset($composerData['extra']['spress_class']) === true && is_string($composerData['extra']['spress_class'])) {
             return $composerData['extra']['spress_class'];
         }
     }
     return '';
 }
开发者ID:jjk-jacky,项目名称:Spress,代码行数:20,代码来源:PluginManagerBuilder.php

示例9: load

 /**
  * Load and parse content from file.
  *
  * @param  SplFileInfo $file
  * @return void
  */
 protected function load(SplFileInfo $file)
 {
     // File info
     $this->filename = $file->getBasename();
     $this->sourcePath = $file->getRelativePath();
     // Load the file
     $data = $file->getContents();
     list($content, $meta) = $this->splitContentMeta($data);
     // Parse meta
     $meta = Yaml::parse($meta) ?: [];
     // Parse content
     switch ($file->getExtension()) {
         case 'md':
         case 'markdown':
             $content = Markdown::parse($content);
             $this->type = self::TYPE_MARKDOWN;
             break;
         case 'tx':
         case 'textile':
             $content = Textile::parse($content);
             $this->type = self::TYPE_TEXTILE;
             break;
     }
     // Set content
     $this->content = $content;
     $this->meta = $meta;
     // Ensure local URLs are absolute
     foreach ($this->meta as $key => $value) {
         if (preg_match('/\\burl\\b|.*_url\\b/', $key)) {
             $this->meta[$key] = $this->builder->getUrl($value);
         }
     }
     // Set target
     $this->setTarget($file);
     // Pagination enabled
     $this->paginate = isset($this->meta['paginate']);
     // Get parent page
     if ($root = dirname(dirname($this->target))) {
         if ($root !== DIRECTORY_SEPARATOR) {
             $this->parentId = ltrim($root, '/');
         }
     }
     // Set URL
     $this->url = '/' . trim(str_replace([DIRECTORY_SEPARATOR, '//'], ['/', '/'], $this->target), '/');
     // Remove "index.html" from the end, this provides a cleaner URL
     if (substr($this->url, -10) === 'index.html') {
         $this->url = substr($this->url, 0, -10);
     }
     // Set basic values
     $this->id = trim($this->url, '/') ?: 'root';
     $this->title = $this->get('title');
     $this->url = $this->builder->getUrl($this->url);
     // Set Description
     if ($this->has('description')) {
         $this->description = $this->get('description');
     } else {
         $this->description = $this->getDescription();
     }
 }
开发者ID:torann,项目名称:skosh-generator,代码行数:65,代码来源:Content.php

示例10: isMigration

 /**
  * Проверяет является ли класс миграцией.
  * @param SplFileInfo $file файл
  * @return bool|IMigration
  */
 protected function isMigration(SplFileInfo $file)
 {
     require_once $file->getPathname();
     $className = $file->getBasename('.php');
     $migration = new $className();
     if (!$migration instanceof IMigration) {
         return false;
     }
     return $migration;
 }
开发者ID:georgynet,项目名称:migration,代码行数:15,代码来源:BaseMigrationCommand.php

示例11: getBasename

 public function getBasename($suffix = null)
 {
     return $this->fileInfo->getBasename($suffix);
 }
开发者ID:phramz,项目名称:doctrine-annotation-scanner,代码行数:4,代码来源:ClassFileInfo.php

示例12: getImageSavePath

 /**
  * 获取图像文件保存路径
  * @param SplFileInfo $fileInfo
  * @return string
  */
 protected function getImageSavePath(SplFileInfo $fileInfo)
 {
     return $this->savePath . '/' . $fileInfo->getBasename(true);
 }
开发者ID:slince,项目名称:magic-hand,代码行数:9,代码来源:MagicHand.php

示例13: parseScenario

 /**
  * @param string      $scenario
  * @param SplFileInfo $fileInfo
  *
  * @todo make it event driven
  *
  * @return string
  */
 public function parseScenario($scenario, $fileInfo)
 {
     $feature = '';
     list($title, $body) = explode(PHP_EOL, $scenario, 2);
     $feature .= '### ' . $title . PHP_EOL . PHP_EOL . $body . PHP_EOL . PHP_EOL;
     $path = $fileInfo->getPath() . '/' . $fileInfo->getBasename('.feature');
     if (is_dir($path)) {
         $targetFile = $path . '/' . $this->sanitizeFileName($title) . '.md';
         if (is_readable($targetFile)) {
             $feature .= file_get_contents($targetFile) . PHP_EOL . PHP_EOL;
         }
     }
     return $feature;
 }
开发者ID:sourcerer-mike,项目名称:mdoc,代码行数:22,代码来源:Merge.php

示例14: extractStringTokens

 /**
  * Extract all strings from a given file.
  *
  * @param SplFileInfo $file
  *
  * @return string[]
  */
 protected function extractStringTokens(SplFileInfo $file)
 {
     // Fetch tokens from cache if available
     $hash = 'janitor.tokens.' . md5($file->getPathname()) . '-' . $file->getMTime();
     return $this->cache->rememberForever($hash, function () use($file) {
         $contents = $file->getContents();
         // See if we have an available Tokenizer
         // and use it to extract the contents
         switch ($file->getExtension()) {
             case 'php':
                 $tokenizer = strpos($file->getBasename(), 'blade.php') !== false ? new BladeTokenizer() : new PhpTokenizer();
                 break;
             case 'twig':
                 $tokenizer = new TwigTokenizer();
                 break;
             case 'json':
                 $tokenizer = new JsonTokenizer();
                 break;
             case 'yml':
             case 'yaml':
                 $tokenizer = new YamlTokenizer();
                 break;
             case 'xml':
                 $tokenizer = new XmlTokenizer();
                 break;
             default:
                 $tokenizer = new DefaultTokenizer();
                 break;
         }
         return $tokenizer->tokenize($contents);
     });
 }
开发者ID:anahkiasen,项目名称:janitor,代码行数:39,代码来源:Codebase.php

示例15: getClassReflection

 /**
  * Get Class Reflection Instance
  *
  * @access protected
  * @throws \LogicException
  * @param \Symfony\Component\Finder\SplFileInfo $file
  * @param string $namespace
  * @param string $suffix
  * @param string $parent
  * @param integer $allowedParameters
  * @return \Darsyn\ClassFinder\Reflection\ReflectionClass
  */
 protected function getClassReflection(SplFileInfo $file, $namespace, $suffix, $parent, $allowedParameters)
 {
     // Determine the fully-qualified class name of the found file.
     $class = preg_replace('#\\\\{2,}#', '\\', sprintf('%s\\%s\\%s', $namespace, strtr($file->getRelativePath(), '/', '\\'), $file->getBasename($this->extension)));
     // Make sure that the class name has the correct suffix.
     if (!empty($suffix) && substr($class, 0 - strlen($suffix)) !== $suffix) {
         throw new \LogicException(sprintf('The file found at "%s" does not end with the required suffix of "%s".', $file->getRealPath(), $suffix));
     }
     // We have to perform a few checks on the class before we can return it.
     // - It must be an actual class; not interface, abstract or trait types.
     // - For this to work the constructor must not have more than the expected number of required parameters.
     // - And finally make sure that the class loaded was actually loaded from the directory we found it in.
     //   TODO: Make sure that the final (file path) check doesn't cause problems with proxy classes or
     //         bootstraped/compiled class caches.
     $reflect = new ReflectionClass($class, $file->getRelativePath());
     if (is_object($construct = $reflect->getConstructor()) && $construct->getNumberOfRequiredParameters() > $allowedParameters || $reflect->isAbstract() || $reflect->isInterface() || $reflect->isTrait() || is_string($parent) && !empty($parent) && !$reflect->isSubclassOf($parent) || $reflect->getFileName() !== $file->getRealPath()) {
         throw new \LogicException(sprintf('The class definition for "%s" is invalid.', $class));
     }
     return $reflect;
 }
开发者ID:darsyn,项目名称:class-finder,代码行数:32,代码来源:ClassFinder.php


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