Skip to content
This repository has been archived by the owner on Apr 19, 2023. It is now read-only.

Commit

Permalink
不要なイベントを削除
Browse files Browse the repository at this point in the history
  • Loading branch information
ryuring committed Apr 16, 2023
1 parent b6bce5c commit 250c887
Show file tree
Hide file tree
Showing 5 changed files with 1 addition and 247 deletions.
22 changes: 0 additions & 22 deletions plugins/baser-core/src/Controller/Admin/ContentsController.php
Expand Up @@ -210,17 +210,7 @@ public function trash_return(ContentsServiceInterface $service, $id)
$this->ajaxError(500, __d('baser_core', '無効な処理です。'));
}
$this->disableAutoRender();

// EVENT Contents.beforeTrashReturn
$this->dispatchLayerEvent('beforeTrashReturn', [
'data' => $id
]);

if ($restored = $service->restore($id)) {
// EVENT Contents.afterTrashReturn
$this->dispatchLayerEvent('afterTrashReturn', [
'data' => $id
]);
$this->BcMessage->setSuccess(sprintf(__d('baser_core', 'ゴミ箱「%s」を戻しました。'), $restored->title));
return $this->redirect(['action' => 'index']);
} else {
Expand All @@ -237,21 +227,9 @@ public function delete(ContentsServiceInterface $service)
{
if ($this->request->is(['post', 'put', 'delete'])) {
$id = $this->request->getData('content.id');

// EVENT Contents.beforeDelete
$this->dispatchLayerEvent('beforeDelete', [
'data' => $id
]);

/* @var \BaserCore\Model\Entity\Content $content */
$content = $service->get($id);
if ($service->deleteRecursive($id)) {

// EVENT Contents.afterDelete
$this->dispatchLayerEvent('afterDelete', [
'data' => $id
]);

$typeName = Configure::read('BcContents.items.' . $content->plugin . '.' . $content->type . '.title');
if(!$content->alias_id) {
$message = $typeName . sprintf(__d('baser_core', '「%s」をゴミ箱に移動しました。'), $content->title);
Expand Down
47 changes: 0 additions & 47 deletions plugins/baser-core/src/Controller/Api/Admin/ContentsController.php
Expand Up @@ -147,18 +147,7 @@ public function delete(ContentsServiceInterface $service, $id = null)

$content = $service->get($id);
$children = $service->getChildren($id);
// EVENT Contents.beforeDelete
$this->dispatchLayerEvent('beforeDelete', [
'data' => $id
]);

if ($service->deleteRecursive($id)) {

// EVENT Contents.afterDelete
$this->dispatchLayerEvent('afterDelete', [
'data' => $id
]);

$text = __d('baser_core', "コンテンツ: {0}を削除しました。", $content->title);
if ($children) {
$content = array_merge([$content], $children->toArray());
Expand Down Expand Up @@ -197,22 +186,10 @@ public function trash_empty(ContentsServiceInterface $service)
$this->request->allowMethod(['post', 'delete']);
try {
$trash = $service->getTrashIndex($this->request->getQueryParams())->order(['plugin', 'type']);

// EVENT Contents.beforeTrashEmpty
$this->dispatchLayerEvent('beforeTrashEmpty', [
'data' => $trash
]);

$result = true;
foreach ($trash as $entity) {
if (!$service->hardDeleteWithAssoc($entity->id)) $result = false;
}
$message = __d('baser_core', 'ゴミ箱を空にしました。');

// EVENT Contents.afterTrashEmpty
$this->dispatchLayerEvent('afterTrashEmpty', [
'data' => $result
]);
$this->BcMessage->setSuccess($message, true, false);
} catch (RecordNotFoundException $e) {
$this->setResponse($this->response->withStatus(404));
Expand Down Expand Up @@ -309,11 +286,6 @@ public function change_status(ContentsServiceInterface $service)
$id = $this->request->getData('id');
$status = $this->request->getData('status');

// EVENT Contents.beforeChangeStatus
$this->dispatchLayerEvent('beforeChangeStatus', [
'id' => $id,
'status' => $status
]);
$content = $errors = $message = null;
$result = false;
if ($id && $status) {
Expand Down Expand Up @@ -344,12 +316,6 @@ public function change_status(ContentsServiceInterface $service)
$message = __d('baser_core', '無効な処理です。') . __d('baser_core', "データが不足しています");
}

// EVENT Contents.afterChangeStatus
$this->dispatchLayerEvent('afterChangeStatus', [
'id' => $id,
'result' => $result
]);

$this->set([
'content' => $content,
'message' => $message,
Expand Down Expand Up @@ -521,14 +487,6 @@ public function move(ContentsServiceInterface $service)
$url = $content = $errors = null;
if (!$service->isTreeModifiedByAnotherUser($this->getRequest()->getData('listDisplayed'))) {
try {
// EVENT Contents.beforeMove
$event = $this->dispatchLayerEvent('beforeMove', [
'data' => $this->getRequest()->getData()
]);
if ($event !== false) {
$this->getRequest()->withParsedBody($event->getResult() === true ? $event->getData('data') : $event->getResult());
}

$beforeContent = $service->get($this->request->getData('origin.id'));
$beforeUrl = $beforeContent->url;
$content = $service->move($this->request->getData('origin'), $this->request->getData('target'));
Expand All @@ -539,11 +497,6 @@ public function move(ContentsServiceInterface $service)
rawurldecode($content->url)
);
$url = $service->getUrlById($content->id, true);

// EVENT Contents.afterMove
$this->dispatchLayerEvent('afterMove', [
'data' => $content
]);
$this->BcMessage->setSuccess($message, true, false);
} catch (PersistenceFailedException $e) {
$errors = $e->getEntity()->getErrors();
Expand Down
8 changes: 0 additions & 8 deletions plugins/baser-core/src/Model/Table/SitesTable.php
Expand Up @@ -185,14 +185,6 @@ public function getList($mainSiteId = null, $options = [])
'status' => true
], $options);

// EVENT Sites.beforeGetSiteList
$event = $this->dispatchLayerEvent('beforeGetSiteList', [
'options' => $options
]);
if ($event !== false) {
$options = $event->getResult() === true? $event->getData('options') : $event->getResult();
}

$conditions = [];
if (!is_null($options['status'])) {
$conditions = ['status' => $options['status']];
Expand Down
169 changes: 0 additions & 169 deletions plugins/baser-core/src/Model/Table/ToolsTable.php

This file was deleted.

0 comments on commit 250c887

Please sign in to comment.