Commit d1c6cacb authored by Tino Goratsch's avatar Tino Goratsch

added a static class "Filesystem"

parent a8f9b045
......@@ -53,8 +53,7 @@ class Cache
return @unlink($dir);
}
$files = array_diff(scandir($dir), ['.', '..', '.gitignore', '.svn', '.htaccess', '.htpasswd']);
foreach ($files as $file) {
foreach (Filesystem::scandir($dir) as $file) {
$path = "$dir/$file";
if (is_dir($path)) {
......
<?php
namespace ACP3\Core;
/**
* Class Filesystem
* @package ACP3\Core
*/
class Filesystem
{
/**
* @var array
*/
protected static $excluded = ['.', '..', '.gitignore', '.svn', '.htaccess', '.htpasswd'];
/**
* @param $directory
* @param array $excluded
*
* @return array
*/
public static function scandir($directory, array $excluded = [])
{
return array_diff(
scandir($directory),
array_merge(static::$excluded, $excluded)
);
}
}
\ No newline at end of file
......@@ -173,9 +173,8 @@ class Modules
public function getAllModules()
{
if (empty($this->allModules)) {
foreach ($this->vendors->getVendors() as $namespace) {
$modules = array_diff(scandir(MODULES_DIR . $namespace . '/'), ['.', '..', '.gitignore', '.svn', '.htaccess', '.htpasswd']);
foreach ($modules as $module) {
foreach ($this->vendors->getVendors() as $vendor) {
foreach (Filesystem::scandir(MODULES_DIR . $vendor . '/') as $module) {
$info = $this->getModuleInfo($module);
if (!empty($info)) {
$this->allModules[$info['name']] = $info;
......
......@@ -2,6 +2,7 @@
namespace ACP3\Core\Modules;
use ACP3\Core\Cache;
use ACP3\Core\Filesystem;
use ACP3\Core\Lang;
use ACP3\Core\XML;
use ACP3\Modules\ACP3\System\Model;
......@@ -101,7 +102,7 @@ class ModuleInfoCache
{
$infos = [];
$modules = array_diff(scandir(MODULES_DIR . $vendor . '/'), ['.', '..', '.gitignore', '.svn', '.htaccess', '.htpasswd']);
$modules = Filesystem::scandir(MODULES_DIR . $vendor . '/');
if (!empty($modules)) {
foreach ($modules as $module) {
......@@ -177,7 +178,7 @@ class ModuleInfoCache
*/
protected function getModuleName(array $moduleInfo, $moduleName)
{
if (isset($moduleInfo['name']['lang']) && $moduleInfo['name']['lang'] == 'true') {
if (isset($moduleInfo['name']['lang']) && $moduleInfo['name']['lang'] === 'true') {
return $this->lang->t($moduleName, $moduleName);
}
......
<?php
namespace ACP3\Core\Modules;
use ACP3\Core\Filesystem;
/**
* Class Vendors
......@@ -20,7 +21,7 @@ class Vendors
if ($this->vendors === []) {
$this->vendors = array_merge(
['ACP3'],
array_diff(scandir(MODULES_DIR), ['.', '..', 'ACP3', 'Custom']),
Filesystem::scandir(MODULES_DIR, ['ACP3', 'Custom']),
['Custom']
);
}
......
......@@ -3,6 +3,7 @@
namespace ACP3\Installer\Modules\Update\Controller;
use ACP3\Core\Cache;
use ACP3\Core\Filesystem;
use ACP3\Core\Modules;
use ACP3\Installer\Core;
......@@ -64,8 +65,7 @@ class Index extends Core\Modules\Controller
// ...danach die Restlichen
foreach ($this->vendors->getVendors() as $vendor) {
$modules = array_diff(scandir(MODULES_DIR . $vendor . '/'), ['.', '..', '.gitignore', '.svn', '.htaccess', '.htpasswd']);
foreach ($modules as $module) {
foreach (Filesystem::scandir(MODULES_DIR . $vendor . '/') as $module) {
if (in_array(strtolower($module), $coreModules) === false) {
$results[$module] = $this->_returnModuleUpdateResult($module);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment