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)); } /**