1
|
|
|
<?php |
2
|
|
|
namespace Aoe\AoeDbSequenzer\Form; |
3
|
|
|
|
4
|
|
|
/*************************************************************** |
5
|
|
|
* Copyright notice |
6
|
|
|
* |
7
|
|
|
* (c) 2019 AOE GmbH ([email protected]) |
8
|
|
|
* All rights reserved |
9
|
|
|
* |
10
|
|
|
* This script is part of the TYPO3 project. The TYPO3 project is |
11
|
|
|
* free software; you can redistribute it and/or modify |
12
|
|
|
* it under the terms of the GNU General Public License as published by |
13
|
|
|
* the Free Software Foundation; either version 2 of the License, or |
14
|
|
|
* (at your option) any later version. |
15
|
|
|
* |
16
|
|
|
* The GNU General Public License can be found at |
17
|
|
|
* http://www.gnu.org/copyleft/gpl.html. |
18
|
|
|
* |
19
|
|
|
* This script is distributed in the hope that it will be useful, |
20
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
21
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
22
|
|
|
* GNU General Public License for more details. |
23
|
|
|
* |
24
|
|
|
* This copyright notice MUST APPEAR in all copies of the script! |
25
|
|
|
***************************************************************/ |
26
|
|
|
|
27
|
|
|
use Aoe\AoeDbSequenzer\Domain\Model\OverwriteProtection; |
28
|
|
|
use Aoe\AoeDbSequenzer\Domain\Repository\OverwriteProtectionRepository; |
29
|
|
|
use TYPO3\CMS\Backend\Form\NodeFactory; |
30
|
|
|
use TYPO3\CMS\Core\Utility\GeneralUtility; |
31
|
|
|
use TYPO3\CMS\Extbase\Object\ObjectManager; |
32
|
|
|
use TYPO3\CMS\Lang\LanguageService; |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* @package Aoe\AoeDbSequenzer\Form |
36
|
|
|
*/ |
37
|
|
|
abstract class AbstractOverwriteElement |
38
|
|
|
{ |
39
|
|
|
/** |
40
|
|
|
* @param integer $protectedUid |
41
|
|
|
* @param string $tableName |
42
|
|
|
* @return boolean |
43
|
|
|
*/ |
44
|
|
|
protected function hasOverwriteProtection($protectedUid, $tableName) |
45
|
|
|
{ |
46
|
|
|
if (false === is_numeric($protectedUid)) { |
47
|
|
|
return false; |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
$countOverwriteProtections = $this->getOverwriteProtectionRepository() |
51
|
|
|
->findByProtectedUidAndTableName($protectedUid, $tableName) |
52
|
|
|
->count(); |
53
|
|
|
return ($countOverwriteProtections > 0); |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* @param integer $protectedUid |
58
|
|
|
* @param string $tableName |
59
|
|
|
* @return OverwriteProtection |
60
|
|
|
*/ |
61
|
|
|
protected function getOverwriteProtection($protectedUid, $tableName) |
62
|
|
|
{ |
63
|
|
|
return $this->getOverwriteProtectionRepository() |
64
|
|
|
->findByProtectedUidAndTableName($protectedUid, $tableName) |
65
|
|
|
->getFirst(); |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* @return LanguageService |
70
|
|
|
* @codeCoverageIgnore |
71
|
|
|
*/ |
72
|
|
|
protected function getLanguageService() |
73
|
|
|
{ |
74
|
|
|
return $GLOBALS['LANG']; |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
/** |
78
|
|
|
* @return NodeFactory |
79
|
|
|
* @codeCoverageIgnore |
80
|
|
|
*/ |
81
|
|
|
protected function getNodeFactory() |
82
|
|
|
{ |
83
|
|
|
return GeneralUtility::makeInstance(NodeFactory::class); |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
/** |
87
|
|
|
* @return OverwriteProtectionRepository |
88
|
|
|
* @codeCoverageIgnore |
89
|
|
|
*/ |
90
|
|
|
protected function getOverwriteProtectionRepository() |
91
|
|
|
{ |
92
|
|
|
$objectManager = GeneralUtility::makeInstance(ObjectManager::class); |
93
|
|
|
return $objectManager->get(OverwriteProtectionRepository::class); |
94
|
|
|
} |
95
|
|
|
} |
96
|
|
|
|