File: D:/HostingSpaces/SBogers93/fitale.nl/workbench/komma/kms/src/Komma/Kms/Posts/PostController.php
<?php
namespace Komma\Kms\Posts;
/**
* Short description for the file.
*
* @author Komma <info@komma.pro>
* @copyright (c) 2012-2015, Komma Mediadesign
*/
use Komma\Kms\Core\Kms;
use Komma\Kms\Core\SectionController;
use Komma\Kms\Core\Tree\TreeService;
use Komma\Kms\Posts\Models\Post;
class PostController extends SectionController
{
protected $slug = "Posts";
protected $treeService;
/**
* Constructor
* @param Kms $kms
* @param PostSection $section
*/
public function __construct(Kms $kms, PostSection $section, TreeService $treeService)
{
parent::__construct($kms, $section);
$this->treeService = $treeService;
$this->treeService->setRepository($this->section->getRepository());
$this->treeService->setModel(new Post());
}
public function getStructureAsJson()
{
$tree = $this->treeService->getStructureAsJson();
return \Response::json($tree);
}
public function setStructureAsJson()
{
// 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);
}
}