From dbfab6e18758bc903a1fecd08ca7c6dbc93e4641 Mon Sep 17 00:00:00 2001 From: Lukas Kahwe Smith Date: Tue, 8 Oct 2013 22:46:50 +0200 Subject: [PATCH] remove dynamic method calls in the controller --- Controller/TreeBrowserController.php | 31 +++++++++++----------------- 1 file changed, 12 insertions(+), 19 deletions(-) diff --git a/Controller/TreeBrowserController.php b/Controller/TreeBrowserController.php index 3a956eb..f9e25a5 100644 --- a/Controller/TreeBrowserController.php +++ b/Controller/TreeBrowserController.php @@ -32,23 +32,6 @@ public function __construct(TreeInterface $tree) $this->tree = $tree; } - /** - * Helper method to deliver a json node - * - * @param string $path Node to process - * @param string $method Method to execute on the node - * - * @return Response - */ - protected function processNode($path, $method) - { - if (empty($path)) { - $path = '/'; - } - - return new JsonResponse($this->tree->$method($path)); - } - /** * Get a json encoded list of children the specified node has * @@ -61,7 +44,12 @@ protected function processNode($path, $method) public function childrenAction(Request $request) { $path = $request->query->get('root'); - return $this->processNode($path, "getChildren"); + + if (empty($path)) { + $path = '/'; + } + + return new JsonResponse($this->tree->getChildren($path)); } /** @@ -75,7 +63,12 @@ public function childrenAction(Request $request) public function propertiesAction(Request $request) { $path = $request->query->get('root'); - return $this->processNode($path, "getProperties"); + + if (empty($path)) { + $path = '/'; + } + + return new JsonResponse($this->tree->getProperties($path)); } /**