本文整理汇总了PHP中DirectoryIterator::getBasename方法的典型用法代码示例。如果您正苦于以下问题:PHP DirectoryIterator::getBasename方法的具体用法?PHP DirectoryIterator::getBasename怎么用?PHP DirectoryIterator::getBasename使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DirectoryIterator
的用法示例。
在下文中一共展示了DirectoryIterator::getBasename方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: find_plugins
/**
* Find all plugins defined in your Kohana codebase
*/
public function find_plugins()
{
$paths = Kohana::include_paths();
foreach ($paths as $path) {
$dir = $path . self::$plugins_dir;
//if there's no plugin dir skip to the next path
if (!file_exists($dir)) {
continue;
}
// Instantiate a new directory iterator object
$directory = new DirectoryIterator($dir);
if ($directory->isDir()) {
foreach ($directory as $plugin) {
// Is directory?
if ($plugin->isDir() && !$plugin->isDot()) {
// if there's no plugin.php in this folder, ignore it
if (!file_exists($plugin->getPath() . DIRECTORY_SEPARATOR . $directory->getBasename() . DIRECTORY_SEPARATOR . 'plugin.php')) {
continue;
}
// Store plugin in our pool
self::$plugins_pool[$plugin->getFilename()]['plugin'] = ucfirst($plugin->getFilename());
self::$plugins_pool[$plugin->getFilename()]['path'] = $plugin->getPath() . DIRECTORY_SEPARATOR . $directory->getBasename();
}
}
}
}
return $this;
}
示例2: key
/**
* Returns the identifier of the current cache entry pointed to by the cache
* entry iterator.
*
* @return string
* @api
*/
public function key()
{
if ($this->cacheFilesIterator === null) {
$this->rewind();
}
return $this->cacheFilesIterator->getBasename($this->cacheEntryFileExtension);
}
示例3: compileFile
private function compileFile(\DirectoryIterator $file)
{
$tag = file_get_contents($file->getPathname());
$tagName = $file->getBasename('.html');
$jsFunc = $this->extractJsFunction($tag, $tagName);
$tagHtml = $this->removeJsFromTag($tag, $tagName);
$tagHtml = str_replace('"', '\\"', $tagHtml);
$tagHtml = preg_replace("/\r|\n/", "", $tagHtml);
return 'riot.tag("' . $tagName . '", "' . $tagHtml . '", ' . $jsFunc . ');';
}
示例4: pushItem
/**
* Overwrite in children to parse files according to our style.
* @param array $listing
* @param DirectoryIterator $item
*/
public function pushItem(&$listing, DirectoryIterator $entry)
{
if (substr($filename = $entry->getFilename(), -4) == '.css') {
// a reset stylesheet, always used
if (strpos($stylename = $entry->getBasename('.css'), 'tripoli') !== FALSE) {
} else {
array_push($listing, $stylename);
}
}
}
示例5: getBaseFiles
/**
* {@inheritDoc}
*/
protected function getBaseFiles()
{
$iterator = new \DirectoryIterator($this->getLanguageBasePath() . DIRECTORY_SEPARATOR . $this->baselanguage);
$files = array();
while ($iterator->valid()) {
if (!$iterator->isDot() && $iterator->isFile() && $this->isValidSourceFile($iterator->getPathname()) && $this->isNotFileToSkip($iterator->getBasename())) {
$files[] = $iterator->getFilename();
}
$iterator->next();
}
$this->baseFiles = $files;
}
示例6: getTemplateNames
/**
* Returns a list of all template names.
*
* @return string[]
*/
protected function getTemplateNames()
{
/** @var \RecursiveDirectoryIterator $files */
$files = new \DirectoryIterator(dirname(__FILE__) . '/../../../../data/templates');
$template_names = array();
while ($files->valid()) {
$name = $files->getBasename();
// skip abstract files
if (!$files->isDir() || in_array($name, array('.', '..'))) {
$files->next();
continue;
}
$template_names[] = $name;
$files->next();
}
return $template_names;
}
示例7: getAllNames
/**
* Returns a list of all template names.
*
* @return string[]
*/
public function getAllNames()
{
/** @var \RecursiveDirectoryIterator $files */
$files = new \DirectoryIterator($this->getTemplatePath());
$template_names = array();
while ($files->valid()) {
$name = $files->getBasename();
// skip abstract files
if (!$files->isDir() || in_array($name, array('.', '..'))) {
$files->next();
continue;
}
$template_names[] = $name;
$files->next();
}
return $template_names;
}
示例8: execute
/**
* Executes the transformation process.
*
* @throws Zend_Console_Getopt_Exception
*
* @return void
*/
public function execute()
{
if ($this->getQuiet()) {
return;
}
echo 'Available themes:' . PHP_EOL;
/** @var RecursiveDirectoryIterator $files */
$files = new DirectoryIterator(dirname(__FILE__) . '/../../../../data/themes');
while ($files->valid()) {
$name = $files->getBasename();
// skip abstract files
if (!$files->isDir() || in_array($name, array('.', '..'))) {
$files->next();
continue;
}
echo '* ' . $name . PHP_EOL;
$files->next();
}
echo PHP_EOL;
}
示例9: getTemplateNames
/**
* Returns a list of all template names.
*
* @return string[]
*/
protected function getTemplateNames()
{
// TODO: this directory needs to come from the parameter set in the DIC in the ServiceProvider
$template_dir = dirname(__FILE__) . '/../../../../data/templates';
if (!file_exists($template_dir)) {
//Vendored installation
$template_dir = dirname(__FILE__) . '/../../../../../../templates';
}
/** @var \RecursiveDirectoryIterator $files */
$files = new \DirectoryIterator($template_dir);
$template_names = array();
while ($files->valid()) {
$name = $files->getBasename();
// skip abstract files
if (!$files->isDir() || in_array($name, array('.', '..'))) {
$files->next();
continue;
}
$template_names[] = $name;
$files->next();
}
return $template_names;
}
示例10: copyHooksDir
/**
* @param string $src_dir
* @param string $dst_dir
*
* @throws \Exception
*/
protected static function copyHooksDir($src_dir, $dst_dir)
{
$fs = new Filesystem();
$fs->mirror($src_dir, $dst_dir, null, ['override' => true]);
$file = new \DirectoryIterator($src_dir);
$mask = umask();
while ($file->valid()) {
if ($file->isFile() && is_executable($file->getPathname())) {
$fs->chmod("{$dst_dir}/" . $file->getBasename(), 0777, $mask);
}
$file->next();
}
}
示例11: DirectoryIterator
<?php
$targetDir = __DIR__ . DIRECTORY_SEPARATOR . md5('directoryIterator::getbasename2');
mkdir($targetDir);
touch($targetDir . DIRECTORY_SEPARATOR . 'getBasename_test.txt');
$dir = new DirectoryIterator($targetDir . DIRECTORY_SEPARATOR);
while (!$dir->isFile()) {
$dir->next();
}
echo $dir->getBasename(array());
$targetDir = __DIR__ . DIRECTORY_SEPARATOR . md5('directoryIterator::getbasename2');
unlink($targetDir . DIRECTORY_SEPARATOR . 'getBasename_test.txt');
rmdir($targetDir);
示例12: isValidDir
/**
* @param \DirectoryIterator $fileInfo
*
* @return bool
*/
private function isValidDir(\DirectoryIterator $fileInfo)
{
return $fileInfo->isDir() && !$fileInfo->isDot() && stripos($fileInfo->getBasename(), '.') !== 0;
}
示例13: collectGarbage
/**
* Does garbage collection
*
* @return void
* @api
*/
public function collectGarbage()
{
if ($this->frozen === TRUE) {
return;
}
for ($directoryIterator = new \DirectoryIterator($this->cacheDirectory); $directoryIterator->valid(); $directoryIterator->next()) {
if ($directoryIterator->isDot()) {
continue;
}
if ($this->isCacheFileExpired($directoryIterator->getPathname())) {
$this->remove($directoryIterator->getBasename($this->cacheEntryFileExtension));
}
}
}
示例14: DirectoryIterator
<?php
$targetDir = __DIR__ . DIRECTORY_SEPARATOR . md5('directoryIterator::getbasename1');
mkdir($targetDir);
touch($targetDir . DIRECTORY_SEPARATOR . 'getBasename_test.txt');
$dir = new DirectoryIterator($targetDir . DIRECTORY_SEPARATOR);
while (!$dir->isFile()) {
$dir->next();
}
echo $dir->getBasename('.txt');
$targetDir = __DIR__ . DIRECTORY_SEPARATOR . md5('directoryIterator::getbasename1');
unlink($targetDir . DIRECTORY_SEPARATOR . 'getBasename_test.txt');
rmdir($targetDir);
示例15: getBasename
/**
* Get basename of file (without extension
* @return string
*/
public function getBasename()
{
return parent::getBasename('.' . $this->getExtension());
}