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