|
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
|
|
|
|
|
18
|
|
|
namespace TYPO3\CMS\Core\Context; |
|
19
|
|
|
|
|
20
|
|
|
use TYPO3\CMS\Core\Context\Exception\AspectPropertyNotFoundException; |
|
21
|
|
|
|
|
22
|
|
|
/** |
|
23
|
|
|
* The aspect contains whether to show hidden pages, records (content) or even deleted records. |
|
24
|
|
|
* |
|
25
|
|
|
* Allowed properties: |
|
26
|
|
|
* - includeHiddenPages |
|
27
|
|
|
* - includeHiddenContent |
|
28
|
|
|
* - includeDeletedRecords |
|
29
|
|
|
*/ |
|
30
|
|
|
class VisibilityAspect implements AspectInterface |
|
31
|
|
|
{ |
|
32
|
|
|
/** |
|
33
|
|
|
* @var bool |
|
34
|
|
|
*/ |
|
35
|
|
|
protected $includeHiddenPages; |
|
36
|
|
|
|
|
37
|
|
|
/** |
|
38
|
|
|
* @var bool |
|
39
|
|
|
*/ |
|
40
|
|
|
protected $includeHiddenContent; |
|
41
|
|
|
|
|
42
|
|
|
/** |
|
43
|
|
|
* @var bool |
|
44
|
|
|
*/ |
|
45
|
|
|
protected $includeDeletedRecords; |
|
46
|
|
|
|
|
47
|
|
|
/** |
|
48
|
|
|
* @param bool $includeHiddenPages whether to include hidden=1 in pages tables |
|
49
|
|
|
* @param bool $includeHiddenContent whether to include hidden=1 in tables except for pages |
|
50
|
|
|
* @param bool $includeDeletedRecords whether to include deleted=1 records (only for use in recycler) |
|
51
|
|
|
*/ |
|
52
|
|
|
public function __construct(bool $includeHiddenPages = false, bool $includeHiddenContent = false, bool $includeDeletedRecords = false) |
|
53
|
|
|
{ |
|
54
|
|
|
$this->includeHiddenPages = $includeHiddenPages; |
|
55
|
|
|
$this->includeHiddenContent = $includeHiddenContent; |
|
56
|
|
|
$this->includeDeletedRecords = $includeDeletedRecords; |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
/** |
|
60
|
|
|
* Fetch the values |
|
61
|
|
|
* |
|
62
|
|
|
* @param string $name |
|
63
|
|
|
* @return int|bool |
|
64
|
|
|
* @throws AspectPropertyNotFoundException |
|
65
|
|
|
*/ |
|
66
|
|
|
public function get(string $name) |
|
67
|
|
|
{ |
|
68
|
|
|
switch ($name) { |
|
69
|
|
|
case 'includeHiddenPages': |
|
70
|
|
|
return $this->includeHiddenPages; |
|
71
|
|
|
case 'includeHiddenContent': |
|
72
|
|
|
return $this->includeHiddenContent; |
|
73
|
|
|
case 'includeDeletedRecords': |
|
74
|
|
|
return $this->includeDeletedRecords; |
|
75
|
|
|
} |
|
76
|
|
|
throw new AspectPropertyNotFoundException('Property "' . $name . '" not found in Aspect "' . __CLASS__ . '".', 1527780439); |
|
77
|
|
|
} |
|
78
|
|
|
|
|
79
|
|
|
public function includeHidden(): bool |
|
80
|
|
|
{ |
|
81
|
|
|
return $this->includeHiddenContent || $this->includeHiddenPages; |
|
82
|
|
|
} |
|
83
|
|
|
|
|
84
|
|
|
public function includeHiddenPages(): bool |
|
85
|
|
|
{ |
|
86
|
|
|
return $this->includeHiddenPages; |
|
87
|
|
|
} |
|
88
|
|
|
|
|
89
|
|
|
public function includeHiddenContent(): bool |
|
90
|
|
|
{ |
|
91
|
|
|
return $this->includeHiddenContent; |
|
92
|
|
|
} |
|
93
|
|
|
|
|
94
|
|
|
public function includeDeletedRecords(): bool |
|
95
|
|
|
{ |
|
96
|
|
|
return $this->includeDeletedRecords; |
|
97
|
|
|
} |
|
98
|
|
|
} |
|
99
|
|
|
|