public function getChildrenAction($parentId, Request $request)
{
$locale = $this->getRequestParameter($request, 'locale', true);
if ($request->get('flat') == 'true') {
// check if parent exists
$this->getCategoryManager()->findById($parentId);
$list = $this->getListRepresentation($request, $locale, $parentId);
} else {
$entities = $this->getCategoryManager()->findChildrenByParentId($parentId);
$categories = $this->getCategoryManager()->getApiObjects($entities, $locale);
$list = new CollectionRepresentation($categories, self::$entityKey);
}
return $this->handleView($this->view($list, 200));
}