HEX
Server: Microsoft-IIS/8.5
System: Windows NT YDAWBH120 6.3 build 9600 (Windows Server 2012 R2 Standard Edition) AMD64
User: tentjecom_web (0)
PHP: 7.4.14
Disabled: NONE
Upload Files
File: D:/HostingSpaces/PDeckers/opelkapitan.nl/workbench/komma/kms/src/Komma/Kms/Pages/PageController.php
<?php

namespace Komma\Kms\Pages;

/**
 * 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\Pages\Models\Page;

class PageController extends SectionController
{
    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 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);
    }
}