Skip to content

Commit

Permalink
CakePHP5系に対応 fix #2740
Browse files Browse the repository at this point in the history
  • Loading branch information
ryuring committed Jan 17, 2024
1 parent a3390e3 commit 35ff09f
Show file tree
Hide file tree
Showing 665 changed files with 8,980 additions and 15,280 deletions.
14 changes: 12 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,18 @@
._*
.Spotlight-V100
.Trashes
Icon?
# Icon must end with two \r
Icon
ehthumbs.db
Thumbs.db
.directory

# Tool specific files #
#######################
# PHPUnit
.phpunit.cache
.phpunit.result.cache
tests.sqlite
# vim
*~
*.swp
Expand All @@ -41,9 +44,15 @@ Thumbs.db
nbproject/*
# Visual Studio Code
.vscode
# nova
.nova
# Sass preprocessor
.sass-cache/

# node
/node_modules/*
# yarn
yarn-debug.log
yarn-error.log

# baserCMS
######################
Expand Down Expand Up @@ -75,6 +84,7 @@ nbproject/*
!/plugins/bc-column
!/plugins/BcPluginSample
!/plugins/BcThemeSample
!/plugins/cakephp-soft-delete
/plugins/*/vendor
/plugins/*/composer.lock
# vagrant
Expand Down
20 changes: 8 additions & 12 deletions __assets/plugins/baser-core/src/basics.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@
// App::uses('CakeText', 'Utility');
use Cake\Cache\Cache;
use Cake\Utility\Text;
use Cake\Filesystem\File;
use Cake\Filesystem\Folder;
use BaserCore\Utility\BcFolder;
use Cake\Utility\Inflector;
use BaserCore\Utility\BcUtil;

Expand Down Expand Up @@ -183,9 +182,9 @@ function clearViewCache($url = null, $ext = '.php')
clearCache(strtolower(Text::slug($url)), 'views', $ext);
}
} else {
$folder = new Folder(CACHE . 'views' . DS);
$files = $folder->read(true, true);
foreach($files[1] as $file) {
$folder = new BcFolder(CACHE . 'views' . DS);
$files = $folder->getFiles();
foreach ($files as $file) {
if ($file != 'empty') {
@unlink(CACHE . 'views' . DS . $file);
}
Expand All @@ -200,16 +199,13 @@ function clearDataCache()
{

App::import('Core', 'Folder');
$folder = new Folder(CACHE . 'datas' . DS);
$folder = new BcFolder(CACHE . 'datas' . DS);

$files = $folder->read(true, true, true);
foreach($files[1] as $file) {
$files = $folder->getFiles();
foreach ($files as $file) {
@unlink($file);
}
$Folder = new Folder();
foreach($files[0] as $folder) {
$Folder->delete($folder);
}
$folder->delete();
}

/**
Expand Down
40 changes: 18 additions & 22 deletions __assets/plugins/baser-core/tests/TestCase/BcBasicsTest.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php
// TODO : コード確認要
use BaserCore\TestSuite\BcTestCase;
use BaserCore\Utility\BcFile;
use BaserCore\Utility\BcUtil;

return;
Expand Down Expand Up @@ -164,17 +166,17 @@ public function testClearViewCache($url, $ext)
{
$viewCachePath = CACHE . 'views' . DS;
if ($url == '/' || $url == '/index' || $url == '/index.html' || $url == '/m/' || $url == '/m/index' || $url == '/m/index.html') {
$cache = new File($viewCachePath . DS . strtolower(Inflector::slug($url)) . $ext, true);
$cache = new BcFile($viewCachePath . DS . strtolower(Inflector::slug($url)) . $ext);
// 削除実行
clearViewCache($url, $ext);

} elseif ($url) {
// ダミーのキャッシュファイルを生成
$cache = new File($viewCachePath . DS . strtolower(Inflector::slug($url)) . $ext, true);
$cacheHoge = new File($viewCachePath . DS . strtolower(Inflector::slug($url)) . '.hoge', true);
$cache = new BcFile($viewCachePath . DS . strtolower(Inflector::slug($url)) . $ext);
$cacheHoge = new BcFile($viewCachePath . DS . strtolower(Inflector::slug($url)) . '.hoge');
if (preg_match('/\/index$/', $url)) {
$replacedUrl = preg_replace('/\/index$/', '', $url);
$replacedCache = new File($viewCachePath . DS . strtolower(Inflector::slug($replacedUrl)) . $ext, true);
$replacedCache = new BcFile($viewCachePath . DS . strtolower(Inflector::slug($replacedUrl)) . $ext);
}
// 削除実行
clearViewCache($url, $ext);
Expand All @@ -191,8 +193,8 @@ public function testClearViewCache($url, $ext)

} else {
// ダミーのキャッシュファイルを生成
$cache = new File($viewCachePath . DS . 'cache', true);
$empty = new File($viewCachePath . DS . 'empty', true);
$cache = new BcFile($viewCachePath . DS . 'cache');
$empty = new BcFile($viewCachePath . DS . 'empty');

// 削除実行
clearViewCache($url, $ext);
Expand Down Expand Up @@ -240,26 +242,20 @@ public function testClearAllCache()
$envConf = Cache::config('_bc_env_');
$envConf = $envConf['settings'];

$coreCache = new File($coreConf['path'] . $coreConf['prefix'] . 'cache', true);
$modelCache = new File($modelConf['path'] . $modelConf['prefix'] . 'cache', true);
$envCache = new File($envConf['path'] . $envConf['prefix'] . 'cache', true);
$viewCache = new File(CACHE . 'views' . DS . 'cache', true);
$dataCache = new File(CACHE . 'datas' . DS . 'cache', true);
$coreCache = new BcFile($coreConf['path'] . $coreConf['prefix'] . 'cache');
$modelCache = new BcFile($modelConf['path'] . $modelConf['prefix'] . 'cache');
$envCache = new BcFile($envConf['path'] . $envConf['prefix'] . 'cache');
$viewCache = new BcFile(CACHE . 'views' . DS . 'cache');
$dataCache = new BcFile(CACHE . 'datas' . DS . 'cache');

// キャッシュ削除
BcUtil::clearAllCache();

$this->assertFalse($coreCache->exists());
$this->assertFalse($modelCache->exists());
$this->assertFalse($envCache->exists());
$this->assertFalse($viewCache->exists());
$this->assertFalse($dataCache->exists());

$coreCache->close();
$modelCache->close();
$envCache->close();
$viewCache->close();
$dataCache->close();
$this->assertFalse(is_file($coreCache->getPath()));
$this->assertFalse(is_file($modelCache->getPath()));
$this->assertFalse(is_file($envCache->getPath()));
$this->assertFalse(is_file($viewCache->getPath()));
$this->assertFalse(is_file($dataCache->getPath()));
}

/**
Expand Down
47 changes: 47 additions & 0 deletions bin/bash_completion.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#
# Bash completion file for CakePHP console.
# Copy this file to a file named `cake` under `/etc/bash_completion.d/`.
# For more info check https://book.cakephp.org/5/en/console-commands/completion.html#how-to-enable-bash-autocompletion-for-the-cakephp-console
#

_cake()
{
local cur prev opts cake
COMPREPLY=()
cake="${COMP_WORDS[0]}"
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"

if [[ "$cur" == -* ]] ; then
if [[ ${COMP_CWORD} = 1 ]] ; then
opts=$(${cake} completion options)
elif [[ ${COMP_CWORD} = 2 ]] ; then
opts=$(${cake} completion options "${COMP_WORDS[1]}")
else
opts=$(${cake} completion options "${COMP_WORDS[1]}" "${COMP_WORDS[2]}")
fi

COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
return 0
fi

if [[ ${COMP_CWORD} = 1 ]] ; then
opts=$(${cake} completion commands)
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
return 0
fi

if [[ ${COMP_CWORD} = 2 ]] ; then
opts=$(${cake} completion subcommands $prev)
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
if [[ $COMPREPLY = "" ]] ; then
_filedir
return 0
fi
return 0
fi

return 0
}

complete -F _cake cake bin/cake
2 changes: 0 additions & 2 deletions bin/cake.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#!/usr/bin/php -q
<?php
// Check platform requirements
require dirname(__DIR__) . '/config/requirements.php';
require dirname(__DIR__) . '/vendor/autoload.php';

use App\Application;
Expand Down
33 changes: 20 additions & 13 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,31 @@
"type": "project",
"license": "MIT",
"require": {
"php": ">=8.0",
"php": ">=8.1",
"ext-gd": "*",
"ext-json": "*",
"ext-mbstring": "*",
"ext-pdo": "*",
"cakephp/authentication": "^2.9",
"cakephp/cakephp": "4.4.*",
"cakephp/migrations": "^3.2",
"ext-sqlite3": "*",
"ext-zip": "*",
"cakephp/authentication": "^3.0",
"cakephp/cakephp": "5.0.*",
"cakephp/migrations": "^4.0.0",
"cakephp/plugin-installer": "^2.0",
"doctrine/annotations": "^1.12",
"firebase/php-jwt": "6.1.0",
"imo-tikuwa/cakephp-soft-delete": "^2.0",
"josegonzalez/dotenv": "^3.2",
"mobiledetect/mobiledetectlib": "^2.8"
"mobiledetect/mobiledetectlib": "^4.8.03"
},
"require-dev": {
"cakephp/bake": "^2.6",
"cakephp/debug_kit": "^4.5",
"phpunit/phpunit": "^9.5",
"ext-xdebug": "*",
"cakephp/bake": "^3.0.0",
"cakephp/cakephp-codesniffer": "^5.0",
"cakephp/debug_kit": "^5.0.0",
"phpunit/phpunit": "^10.1.0",
"symplify/monorepo-builder": "^10.2",
"vierge-noire/cakephp-fixture-factories": "^2.5",
"vierge-noire/cakephp-test-suite-light": "^2.0"
"vierge-noire/cakephp-fixture-factories": "^3.0",
"vierge-noire/cakephp-test-suite-light": "^3.0"
},
"suggest": {
"markstory/asset_compress": "An asset compression plugin which provides file concatenation and a flexible filter system for preprocessing and minification.",
Expand Down Expand Up @@ -52,7 +57,8 @@
"BcThemeFile\\": "plugins/bc-theme-file/src/",
"BcUploader\\": "plugins/bc-uploader/src/",
"BcWidgetArea\\": "plugins/bc-widget-area/src/",
"Cake\\Routing\\": "plugins/baser-core/src/Routing"
"Cake\\Routing\\": "plugins/baser-core/src/Routing",
"SoftDelete\\": "plugins/cakephp-soft-delete/src"
}
},
"autoload-dev": {
Expand All @@ -69,7 +75,8 @@
"BcThemeConfig\\Test\\": "plugins/bc-theme-config/tests/",
"BcThemeFile\\Test\\": "plugins/bc-theme-file/tests/",
"BcUploader\\Test\\": "plugins/bc-uploader/tests/",
"BcWidgetArea\\Test\\": "plugins/bc-widget-area/tests/"
"BcWidgetArea\\Test\\": "plugins/bc-widget-area/tests/",
"SoftDelete\\Test\\": "plugins/cakephp-soft-delete/tests"
}
},
"replace": {
Expand Down
Loading

0 comments on commit 35ff09f

Please sign in to comment.