File: D:/HostingSpaces/SBogers85/equichecker.com/app/KommaApp/Pages/Kms/PageController.php
<?php
namespace KommaApp\Pages\Kms;
/**
*
*
* @author Komma <info@komma.pro>
* @copyright (c) 2012-2016, Komma Mediadesign
*/
use KommaApp\Kms\Core\Kms;
use KommaApp\Kms\Core\SiteSectionController;
use KommaApp\Kms\Core\Tree\TreeService;
use KommaApp\Pages\Models\Page;
class PageController extends SiteSectionController
{
protected $slug = "pages";
protected $treeService;
/**
* Constructor
* @param Kms $kms
* @param PageSection $section
*/
public function __construct(Kms $kms, PageSection $section, TreeService $treeService)
{
parent::__construct($kms, $section);
$this->treeService = $treeService;
$this->treeService->setRepository($this->section->getRepository());
$this->treeService->setModel(new Page());
}
public function getPageStructureAsJson()
{
$tree = $this->treeService->getStructure();
return \Response::json($tree);
}
public function setPageStructureAsJson()
{
// 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);
}
}