|
1
|
|
|
<?php |
|
2
|
|
|
namespace EWW\Dpf\Controller; |
|
3
|
|
|
|
|
4
|
|
|
/* |
|
5
|
|
|
* This file is part of the TYPO3 CMS project. |
|
6
|
|
|
* |
|
7
|
|
|
* It is free software; you can redistribute it and/or modify it under |
|
8
|
|
|
* the terms of the GNU General Public License, either version 2 |
|
9
|
|
|
* of the License, or any later version. |
|
10
|
|
|
* |
|
11
|
|
|
* For the full copyright and license information, please read the |
|
12
|
|
|
* LICENSE.txt file that was distributed with this source code. |
|
13
|
|
|
* |
|
14
|
|
|
* The TYPO3 project - inspiring people to share! |
|
15
|
|
|
*/ |
|
16
|
|
|
|
|
17
|
|
|
use EWW\Dpf\Services\Transfer\ElasticsearchRepository; |
|
18
|
|
|
|
|
19
|
|
|
class DocumentFormBEController extends AbstractDocumentFormController |
|
20
|
|
|
{ |
|
21
|
|
|
|
|
22
|
|
|
public function __construct() |
|
23
|
|
|
{ |
|
24
|
|
|
parent::__construct(); |
|
25
|
|
|
|
|
26
|
|
|
} |
|
27
|
|
|
|
|
28
|
|
|
protected function redirectToList($message = null) |
|
29
|
|
|
{ |
|
30
|
|
|
$this->redirect('list', 'Document', null, array('message' => $message)); |
|
31
|
|
|
} |
|
32
|
|
|
|
|
33
|
|
|
/** |
|
34
|
|
|
* action delete |
|
35
|
|
|
* |
|
36
|
|
|
* @param array $documentData |
|
37
|
|
|
* @throws \Exception |
|
38
|
|
|
*/ |
|
39
|
|
|
public function deleteAction($documentData) |
|
40
|
|
|
{ |
|
41
|
|
|
|
|
42
|
|
|
if (!$GLOBALS['BE_USER']) { |
|
43
|
|
|
throw new \Exception('Access denied'); |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
$document = $this->documentRepository->findByUid($documentData['documentUid']); |
|
47
|
|
|
|
|
48
|
|
|
$elasticsearchRepository = $this->objectManager->get(ElasticsearchRepository::class); |
|
49
|
|
|
// send document to index |
|
50
|
|
|
$elasticsearchRepository->delete($document, ""); |
|
51
|
|
|
|
|
52
|
|
|
$document->setState(\EWW\Dpf\Domain\Model\Document::OBJECT_STATE_LOCALLY_DELETED); |
|
53
|
|
|
$document = $this->documentRepository->update($document); |
|
|
|
|
|
|
54
|
|
|
|
|
55
|
|
|
$this->redirectToList(); |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
public function editAction(\EWW\Dpf\Domain\Model\DocumentForm $documentForm) |
|
59
|
|
|
{ |
|
60
|
|
|
|
|
61
|
|
|
$document = $this->documentRepository->findByUid($documentForm->getDocumentUid()); |
|
62
|
|
|
$this->view->assign('document', $document); |
|
63
|
|
|
parent::editAction($documentForm); |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
|
|
67
|
|
|
public function createAction(\EWW\Dpf\Domain\Model\DocumentForm $newDocumentForm) |
|
68
|
|
|
{ |
|
69
|
|
|
parent::createAction($newDocumentForm); |
|
70
|
|
|
$this->redirectToList('CREATE_OK'); |
|
71
|
|
|
} |
|
72
|
|
|
} |
|
73
|
|
|
|