vendor/pimcore/pimcore/bundles/AdminBundle/Controller/Admin/Document/FolderController.php line 39

Open in your IDE?
  1. <?php
  2. /**
  3.  * Pimcore
  4.  *
  5.  * This source file is available under two different licenses:
  6.  * - GNU General Public License version 3 (GPLv3)
  7.  * - Pimcore Commercial License (PCL)
  8.  * Full copyright and license information is available in
  9.  * LICENSE.md which is distributed with this source code.
  10.  *
  11.  *  @copyright  Copyright (c) Pimcore GmbH (http://www.pimcore.org)
  12.  *  @license    http://www.pimcore.org/license     GPLv3 and PCL
  13.  */
  14. namespace Pimcore\Bundle\AdminBundle\Controller\Admin\Document;
  15. use Pimcore\Model\Document;
  16. use Symfony\Component\HttpFoundation\JsonResponse;
  17. use Symfony\Component\HttpFoundation\Request;
  18. use Symfony\Component\Routing\Annotation\Route;
  19. /**
  20.  * @Route("/folder", name="pimcore_admin_document_folder_")
  21.  *
  22.  * @internal
  23.  */
  24. class FolderController extends DocumentControllerBase
  25. {
  26.     /**
  27.      * @Route("/get-data-by-id", name="getdatabyid", methods={"GET"})
  28.      *
  29.      * @param Request $request
  30.      *
  31.      * @return JsonResponse
  32.      *
  33.      * @throws \Exception
  34.      */
  35.     public function getDataByIdAction(Request $request): JsonResponse
  36.     {
  37.         $folder Document\Folder::getById((int)$request->get('id'));
  38.         if (!$folder) {
  39.             throw $this->createNotFoundException('Folder not found');
  40.         }
  41.         $folder = clone $folder;
  42.         $folder->setParent(null);
  43.         $data $folder->getObjectVars();
  44.         $data['locked'] = $folder->isLocked();
  45.         $this->addTranslationsData($folder$data);
  46.         $this->minimizeProperties($folder$data);
  47.         return $this->preSendDataActions($data$folder);
  48.     }
  49.     /**
  50.      * @Route("/save", name="save", methods={"PUT", "POST"})
  51.      *
  52.      * @param Request $request
  53.      *
  54.      * @return JsonResponse
  55.      *
  56.      * @throws \Exception
  57.      */
  58.     public function saveAction(Request $request): JsonResponse
  59.     {
  60.         $folder Document\Folder::getById((int) $request->get('id'));
  61.         if (!$folder) {
  62.             throw $this->createNotFoundException('Folder not found');
  63.         }
  64.         $result $this->saveDocument($folder$requestfalseself::TASK_PUBLISH);
  65.         /** @var Document\Folder $folder */
  66.         $folder $result[1];
  67.         $treeData $this->getTreeNodeConfig($folder);
  68.         return $this->adminJson(['success' => true'treeData' => $treeData]);
  69.     }
  70.     /**
  71.      * @param Request $request
  72.      * @param Document $folder
  73.      */
  74.     protected function setValuesToDocument(Request $requestDocument $folder)
  75.     {
  76.         $this->addPropertiesToDocument($request$folder);
  77.     }
  78. }