‪TYPO3CMS  11.5
OpenDocumentController.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
19 
20 use Psr\Http\Message\ResponseInterface;
21 use Psr\Http\Message\ServerRequestInterface;
26 
34 {
38  protected ‪$documents;
39 
43  protected ‪$toolbarItem;
44 
48  public function ‪__construct()
49  {
50  $this->documents = GeneralUtility::makeInstance(OpenDocumentService::class);
51  $this->toolbarItem = GeneralUtility::makeInstance(OpendocsToolbarItem::class);
52  }
53 
59  public function ‪renderMenu(): ResponseInterface
60  {
61  return new ‪HtmlResponse($this->toolbarItem->getDropDown());
62  }
63 
70  public function ‪closeDocument(ServerRequestInterface $request): ResponseInterface
71  {
72  $identifier = $request->getParsedBody()['md5sum'] ?? $request->getQueryParams()['md5sum'] ?? null;
73 
74  if ($identifier) {
75  $this->documents->closeDocument($identifier);
76  } else {
77  $this->documents->closeAllDocuments();
78  }
79 
80  return $this->‪renderMenu();
81  }
82 }
‪TYPO3\CMS\Opendocs\Backend\ToolbarItems\OpendocsToolbarItem
Definition: OpendocsToolbarItem.php:35
‪TYPO3\CMS\Opendocs\Controller\OpenDocumentController\closeDocument
‪ResponseInterface closeDocument(ServerRequestInterface $request)
Definition: OpenDocumentController.php:68
‪TYPO3\CMS\Opendocs\Controller\OpenDocumentController\__construct
‪__construct()
Definition: OpenDocumentController.php:46
‪TYPO3\CMS\Opendocs\Controller\OpenDocumentController\$toolbarItem
‪OpendocsToolbarItem $toolbarItem
Definition: OpenDocumentController.php:41
‪TYPO3\CMS\Opendocs\Controller\OpenDocumentController\renderMenu
‪ResponseInterface renderMenu()
Definition: OpenDocumentController.php:57
‪TYPO3\CMS\Opendocs\Controller\OpenDocumentController\$documents
‪OpenDocumentService $documents
Definition: OpenDocumentController.php:37
‪TYPO3\CMS\Opendocs\Service\OpenDocumentService
Definition: OpenDocumentService.php:27
‪TYPO3\CMS\Opendocs\Controller\OpenDocumentController
Definition: OpenDocumentController.php:34
‪TYPO3\CMS\Opendocs\Controller
Definition: OpenDocumentController.php:18
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:50
‪TYPO3\CMS\Core\Http\HtmlResponse
Definition: HtmlResponse.php:26