From 5296be5a0009e13e2915a2ef20a7d0d5a0c1a75d Mon Sep 17 00:00:00 2001 From: Christian Fasching Date: Thu, 21 Dec 2017 12:41:14 +0100 Subject: [PATCH] updated controller to be compatible with Pimcore 5.1 --- composer.json | 2 +- .../Controller/ConfigController.php | 48 +++++++++---------- 2 files changed, 25 insertions(+), 25 deletions(-) diff --git a/composer.json b/composer.json index e014eac..c753579 100644 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "name": "elements/export-toolkit-bundle", "type": "pimcore-bundle", "require": { - "pimcore/core-version": "<=5.1" + "pimcore/core-version": "~5.1.0" }, "suggest": { "elements/process-manager-bundle": "~1.0" diff --git a/src/Elements/Bundle/ExportToolkitBundle/Controller/ConfigController.php b/src/Elements/Bundle/ExportToolkitBundle/Controller/ConfigController.php index f757b30..31b224f 100644 --- a/src/Elements/Bundle/ExportToolkitBundle/Controller/ConfigController.php +++ b/src/Elements/Bundle/ExportToolkitBundle/Controller/ConfigController.php @@ -112,7 +112,7 @@ public function listAction(Request $request) } } - return $this->json($tree); + return $this->adminJson($tree); } /** @@ -134,9 +134,9 @@ public function deleteAction(Request $request) $config->delete(); - return $this->json(['success' => true]); + return $this->adminJson(['success' => true]); } catch (Exception $e) { - return $this->json(['success' => false, 'message' => $e->getMessage()]); + return $this->adminJson(['success' => false, 'message' => $e->getMessage()]); } } @@ -159,9 +159,9 @@ public function addFolderAction(Request $request) Dao::addFolder($parent, $name); - return $this->json(['success' => true]); + return $this->adminJson(['success' => true]); } catch (Exception $exception) { - return $this->json(['success' => false, 'message' => $exception->getMessage()]); + return $this->adminJson(['success' => false, 'message' => $exception->getMessage()]); } } @@ -179,9 +179,9 @@ public function deleteFolderAction(Request $request) if (Dao::getFolderByPath($path)) { Dao::deleteFolder($path); - return $this->json(['success' => true]); + return $this->adminJson(['success' => true]); } else { - return $this->json(['success' => false]); + return $this->adminJson(['success' => false]); } } @@ -241,9 +241,9 @@ public function addAction(Request $request) $config = new Configuration($path, $name); $config->save(); - return $this->json(['success' => true, 'name' => $name]); + return $this->adminJson(['success' => true, 'name' => $name]); } catch (Exception $e) { - return $this->json(['success' => false, 'message' => $e->getMessage()]); + return $this->adminJson(['success' => false, 'message' => $e->getMessage()]); } } @@ -273,9 +273,9 @@ public function cloneAction(Request $request) $originalConfig->setName($name); $originalConfig->save($name); - return $this->json(['success' => true, 'name' => $name]); + return $this->adminJson(['success' => true, 'name' => $name]); } catch (Exception $e) { - return $this->json(['success' => false, 'message' => $e->getMessage()]); + return $this->adminJson(['success' => false, 'message' => $e->getMessage()]); } } @@ -303,7 +303,7 @@ public function getAction(Request $request) $cli = $this->getCliCommand($configuration->getName()); } - return $this->json( + return $this->adminJson( [ 'name' => $configuration->getName(), 'execute' => $cli, @@ -330,9 +330,9 @@ public function saveAction(Request $request) $config->setConfiguration($dataDecoded); $config->save(); - return $this->json(['success' => true]); + return $this->adminJson(['success' => true]); } catch (Exception $e) { - return $this->json(['success' => false, 'message' => $e->getMessage()]); + return $this->adminJson(['success' => false, 'message' => $e->getMessage()]); } } @@ -407,7 +407,7 @@ public function getClassesAction(Request $request) } } - return $this->json($implementsIConfig); + return $this->adminJson($implementsIConfig); } else { if ($request->get('type') == 'export-filter') { $implementsIConfig = []; @@ -424,7 +424,7 @@ public function getClassesAction(Request $request) } } - return $this->json($implementsIConfig); + return $this->adminJson($implementsIConfig); } else { if ($request->get('type') == 'export-conditionmodificator') { $implementsIConfig = []; @@ -441,7 +441,7 @@ public function getClassesAction(Request $request) } } - return $this->json($implementsIConfig); + return $this->adminJson($implementsIConfig); } else { if ($request->get('type') == 'attribute-getter') { $implementsIConfig = []; @@ -458,7 +458,7 @@ public function getClassesAction(Request $request) } } - return $this->json($implementsIConfig); + return $this->adminJson($implementsIConfig); } else { if ($request->get('type') == 'attribute-interpreter') { $implementsIConfig = []; @@ -475,7 +475,7 @@ public function getClassesAction(Request $request) } } - return $this->json($implementsIConfig); + return $this->adminJson($implementsIConfig); } else { throw new Exception('unknown class type'); } @@ -523,12 +523,12 @@ public function executeExportAction(Request $request) try { $className::execute($workername, null); } catch (Exception $e) { - return $this->json(['success' => false, 'message' => $e->getMessage()]); + return $this->adminJson(['success' => false, 'message' => $e->getMessage()]); } } else { $lockkey = 'exporttoolkit_'.$workername; if (\Pimcore\Model\Tool\Lock::isLocked($lockkey, 3 * 60 * 60)) { //lock for 3h - return $this->json(['success' => false]); + return $this->adminJson(['success' => false]); } $cmd = $this->getCliCommand($workername); @@ -539,7 +539,7 @@ public function executeExportAction(Request $request) ); } - return $this->json(['success' => true]); + return $this->adminJson(['success' => true]); } /** @@ -555,9 +555,9 @@ public function isExportRunningAction(Request $request) $lockkey = 'exporttoolkit_'.$workername; if (\Pimcore\Model\Tool\Lock::isLocked($lockkey, 3 * 60 * 60)) { //lock for 3h - return $this->json(['success' => true, 'locked' => true]); + return $this->adminJson(['success' => true, 'locked' => true]); } else { - return $this->json(['success' => true, 'locked' => false]); + return $this->adminJson(['success' => true, 'locked' => false]); } } }