Browse Source

"yii\helpers\StringHelper" usage has been added to "yii\helpers\base\FileHelper".

tags/2.0.0-beta
Klimov Paul 12 years ago
parent
commit
40a005d543
  1. 8
      framework/yii/helpers/base/FileHelper.php

8
framework/yii/helpers/base/FileHelper.php

@ -10,6 +10,7 @@
namespace yii\helpers\base; namespace yii\helpers\base;
use Yii; use Yii;
use yii\helpers\StringHelper;
/** /**
* Filesystem helper * Filesystem helper
@ -66,7 +67,7 @@ class FileHelper
if ($language === $sourceLanguage) { if ($language === $sourceLanguage) {
return $file; return $file;
} }
$desiredFile = dirname($file) . DIRECTORY_SEPARATOR . $sourceLanguage . DIRECTORY_SEPARATOR . basename($file); $desiredFile = dirname($file) . DIRECTORY_SEPARATOR . $sourceLanguage . DIRECTORY_SEPARATOR . StringHelper::basename($file);
return is_file($desiredFile) ? $desiredFile : $file; return is_file($desiredFile) ? $desiredFile : $file;
} }
@ -178,10 +179,11 @@ class FileHelper
{ {
$items = glob($dir . DIRECTORY_SEPARATOR . '{,.}*', GLOB_MARK | GLOB_BRACE); $items = glob($dir . DIRECTORY_SEPARATOR . '{,.}*', GLOB_MARK | GLOB_BRACE);
foreach ($items as $item) { foreach ($items as $item) {
if (basename($item) == '.' || basename($item) == '..') { $itemBaseName = StringHelper::basename($item);
if ($itemBaseName === '.' || $itemBaseName === '..') {
continue; continue;
} }
if (substr($item, -1) == DIRECTORY_SEPARATOR) { if (StringHelper::substr($item, -1, 1) == DIRECTORY_SEPARATOR) {
static::removeDirectory($item); static::removeDirectory($item);
} else { } else {
unlink($item); unlink($item);

Loading…
Cancel
Save