File: D:/HostingSpaces/SBogers10/honger7.komma.pro/app/KommaApp/Cases/Kms/CaseController.php
<?php
namespace App\KommaApp\Cases\Kms;
/**
*
*
* @author Komma <info@komma.pro>
* @copyright (c) 2012-2016, Komma
*/
use App\KommaApp\Kms\Core\Kms;
use App\KommaApp\Kms\Core\SiteSectionController;
use App\KommaApp\Kms\Core\Tree\TreeService;
use App\KommaApp\Cases\Models\CaseModel;
class CaseController extends SiteSectionController
{
protected $slug = "cases";
protected $treeService;
/**
* Constructor
* @param Kms $kms
* @param CaseSection $section
*/
public function __construct(Kms $kms, CaseSection $section, TreeService $treeService)
{
parent::__construct($kms, $section);
$this->treeService = $treeService;
$this->treeService->setRepository($this->section->getRepository());
$this->treeService->setModel(new CaseModel());
}
public function getCaseStructureAsJson()
{
$tree = $this->treeService->getStructure();
return \Response::json($tree);
}
public function setCaseStructureAsJson()
{
// Special way to get POST data send by ajax on IIS servers
$data = json_decode(\Request::instance()->getContent());
$tree = json_decode($data->tree);
$tree = $this->treeService->setStructureWithJson($tree);
return \Response::json($tree);
}
}