Skip to content

Commit

Permalink
updated controller to be compatible with Pimcore 5.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Christian Fasching committed Dec 21, 2017
1 parent 9a4a5d5 commit 5296be5
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 25 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public function listAction(Request $request)
}
}

return $this->json($tree);
return $this->adminJson($tree);
}

/**
Expand All @@ -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()]);
}
}

Expand All @@ -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()]);
}
}

Expand All @@ -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]);
}
}

Expand Down Expand Up @@ -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()]);
}
}

Expand Down Expand Up @@ -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()]);
}
}

Expand Down Expand Up @@ -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,
Expand All @@ -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()]);
}
}

Expand Down Expand Up @@ -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 = [];
Expand All @@ -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 = [];
Expand All @@ -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 = [];
Expand All @@ -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 = [];
Expand All @@ -475,7 +475,7 @@ public function getClassesAction(Request $request)
}
}

return $this->json($implementsIConfig);
return $this->adminJson($implementsIConfig);
} else {
throw new Exception('unknown class type');
}
Expand Down Expand Up @@ -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);
Expand All @@ -539,7 +539,7 @@ public function executeExportAction(Request $request)
);
}

return $this->json(['success' => true]);
return $this->adminJson(['success' => true]);
}

/**
Expand All @@ -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]);
}
}
}

0 comments on commit 5296be5

Please sign in to comment.