Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev #2773 bc plugin #2795

Closed
wants to merge 15 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions plugins/baser-core/src/BcPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@
use BaserCore\Service\PermissionGroupsService;
use BaserCore\Service\PermissionGroupsServiceInterface;
use BaserCore\Utility\BcContainerTrait;
use BaserCore\Utility\BcFolder;
use BaserCore\Utility\BcUpdateLog;
use BaserCore\Utility\BcUtil;
use Cake\Core\BasePlugin;
use Cake\Core\Configure;
use Cake\Core\Configure\Engine\PhpConfig;
use Cake\Core\PluginApplicationInterface;
use Cake\Datasource\ConnectionManager;
use Cake\Filesystem\Folder;
use Cake\Http\ServerRequestFactory;
use Cake\I18n\FrozenTime;
use Cake\Log\LogTrait;
Expand Down Expand Up @@ -241,12 +241,12 @@ public function getUpdaters($name = '')

// 有効化されていない可能性があるため CakePlugin::path() は利用しない
$path = BcUtil::getPluginPath($name) . 'config' . DS . 'update';
$folder = new Folder($path);
$files = $folder->read(true, true);
$folder = new BcFolder($path);
$files = $folder->getFolders();
$updaters = [];
$updateVerPoints = [];
if (!empty($files[0])) {
foreach($files[0] as $folder) {
if (!empty($files)) {
foreach($files as $folder) {
$updateVersion = $folder;
$updateVerPoints[$updateVersion] = BcUtil::verpoint($updateVersion);
}
Expand Down Expand Up @@ -289,12 +289,12 @@ public function getUpdateScriptMessages($name = '')

// 有効化されていない可能性があるため CakePlugin::path() は利用しない
$path = BcUtil::getPluginPath($name) . 'config' . DS . 'update';
$folder = new Folder($path);
$files = $folder->read(true, true);
$folder = new BcFolder($path);
$files = $folder->getFolders();
$messages = [];
$updateVerPoints = [];
if (!empty($files[0])) {
foreach($files[0] as $folder) {
if (!empty($files)) {
foreach($files as $folder) {
$updateVersion = $folder;
$updateVerPoints[$updateVersion] = BcUtil::verpoint($updateVersion);
}
Expand Down Expand Up @@ -336,8 +336,8 @@ public function uninstall($options = []): bool

$pluginPath = BcUtil::getPluginPath($pluginName);
if ($pluginPath) {
$Folder = new Folder();
$Folder->delete($pluginPath);
$Folder = new BcFolder($pluginPath);
$Folder->delete();
}
/** @var PermissionGroupsService $permissionGroupsService */
$permissionGroupsService = $this->getService(PermissionGroupsServiceInterface::class);
Expand Down
12 changes: 7 additions & 5 deletions plugins/baser-core/src/Model/Behavior/BcUploadBehavior.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ public function beforeMarshal(EventInterface $event, ArrayObject $data)
{
$this->BcFileUploader[$this->table()->getAlias()]->setupRequestData($data);
$this->BcFileUploader[$this->table()->getAlias()]->setupTmpData($data);
$this->oldEntity[$this->table()->getAlias()] = (!empty($data['id']))? $this->getOldEntity($data['id']) : null;
$this->oldEntity[$this->table()->getAlias()][$data['_bc_upload_id']] = (!empty($data['id']))? $this->getOldEntity($data['id']) : null;
}

/**
Expand Down Expand Up @@ -160,12 +160,14 @@ public function afterMarshal(EventInterface $event, EntityInterface $entity, Arr
*/
public function afterSave(EventInterface $event, EntityInterface $entity)
{
if ($entity->id && !empty($this->oldEntity[$this->table()->getAlias()])) {
$this->BcFileUploader[$this->table()->getAlias()]->deleteExistingFiles($this->oldEntity[$this->table()->getAlias()]);
if ($entity->id && !empty($this->oldEntity[$this->table()->getAlias()][$entity->_bc_upload_id])) {
$oldEntity = $this->oldEntity[$this->table()->getAlias()][$entity->_bc_upload_id];
$oldEntity->_bc_upload_id = $entity->_bc_upload_id;
$this->BcFileUploader[$this->table()->getAlias()]->deleteExistingFiles($oldEntity);
}
$this->BcFileUploader[$this->table()->getAlias()]->saveFiles($entity);
if ($entity->id && !empty($this->oldEntity[$this->table()->getAlias()])) {
$this->BcFileUploader[$this->table()->getAlias()]->deleteFiles($this->oldEntity[$this->table()->getAlias()], $entity);
if ($entity->id && !empty($this->oldEntity[$this->table()->getAlias()][$entity->_bc_upload_id])) {
$this->BcFileUploader[$this->table()->getAlias()]->deleteFiles($this->oldEntity[$this->table()->getAlias()][$entity->_bc_upload_id], $entity);
}
if ($this->BcFileUploader[$this->table()->getAlias()]->isUploaded()) {
$this->BcFileUploader[$this->table()->getAlias()]->renameToBasenameFields($entity);
Expand Down
Loading