Skip to content
This repository was archived by the owner on Sep 16, 2021. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 12 additions & 19 deletions Controller/TreeBrowserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand All @@ -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));
}

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

/**
Expand Down