1 | <?php |
||
23 | class FaqController extends AbstractController |
||
24 | { |
||
25 | const TEASER_MODE_VOTING = 0; |
||
26 | |||
27 | const TEASER_MODE_CUSTOM = 1; |
||
28 | |||
29 | /** |
||
30 | * Question repository. |
||
31 | * |
||
32 | * @var QuestionRepository |
||
33 | */ |
||
34 | protected $questionRepository; |
||
35 | |||
36 | /** |
||
37 | * Question category repository. |
||
38 | * |
||
39 | * @var QuestionCategoryRepository |
||
40 | */ |
||
41 | protected $questionCategoryRepository; |
||
42 | |||
43 | public function __construct(QuestionRepository $questionRepository, QuestionCategoryRepository $questionCategoryRepository) |
||
48 | |||
49 | /** |
||
50 | * Index action. |
||
51 | * |
||
52 | * @throws InvalidQueryException |
||
53 | */ |
||
54 | public function indexAction(Faq $faq = null, bool $showAll = false): void |
||
55 | { |
||
56 | $topCategory = (int)$this->settings['faq']['topCategory']; |
||
57 | |||
58 | if (true === (bool)$this->settings['overrideShowAll']) { |
||
59 | $showAll = true; |
||
60 | } |
||
61 | if (0 !== (int)$this->settings['overrideTopCategory']) { |
||
62 | $topCategory = (int)$this->settings['overrideTopCategory']; |
||
63 | } |
||
64 | |||
65 | if (\is_object($faq)) { |
||
66 | $questions = $this->questionRepository->findByFaq($faq, $topCategory); |
||
67 | $showResults = true; |
||
68 | } elseif ($showAll) { |
||
69 | $showResults = true; |
||
70 | $questions = $this->questionRepository->findAll($topCategory); |
||
71 | } else { |
||
72 | $questions = []; |
||
73 | $showResults = false; |
||
74 | } |
||
75 | |||
76 | if (self::TEASER_MODE_VOTING === (int)$this->settings['topMode']) { |
||
77 | $topQuestions = $this->questionRepository->findTop( |
||
78 | (int)$this->settings['faq']['limitTop'], |
||
79 | $topCategory, |
||
80 | GeneralUtility::intExplode(',', $this->settings['faq']['topQuestions'], true) |
||
81 | ); |
||
82 | } else { |
||
83 | $topQuestions = $this->questionRepository->findByUidsSorted(GeneralUtility::intExplode( |
||
84 | ',', |
||
85 | $this->settings['custom'], |
||
86 | true |
||
87 | )); |
||
88 | } |
||
89 | |||
90 | if (null === $faq) { |
||
91 | $faq = $this->objectManager->get(Faq::class); |
||
|
|||
92 | } |
||
93 | |||
94 | $this->addSchemaOrgHeader($questions); |
||
95 | |||
96 | $this->view->assignMultiple([ |
||
97 | 'showResults' => $showResults, |
||
98 | 'faq' => $faq, |
||
99 | 'questions' => $questions, |
||
100 | 'newQuestions' => $this->questionRepository->findNewest( |
||
101 | (int)$this->settings['faq']['limitNewest'], |
||
102 | $topCategory |
||
103 | ), |
||
104 | 'topQuestions' => $topQuestions, |
||
105 | 'categories' => $this->questionCategoryRepository->findByParent( |
||
106 | $topCategory, |
||
107 | (bool)$this->settings['faq']['categorySort'] ?: false |
||
108 | ), |
||
109 | ]); |
||
110 | } |
||
111 | |||
112 | /** |
||
113 | * Render the teaser action. |
||
114 | */ |
||
115 | public function teaserAction(): void |
||
116 | { |
||
117 | $topQuestions = GeneralUtility::intExplode(',', $this->settings['faq']['topQuestions'], true); |
||
118 | $teaserCategories = GeneralUtility::intExplode(',', $this->settings['faq']['teaserCategories'], true); |
||
119 | $teaserLimit = (int)$this->settings['faq']['teaserLimit']; |
||
120 | $questions = $this->questionRepository->findByTeaserConfiguration( |
||
121 | $topQuestions, |
||
122 | $teaserCategories, |
||
123 | $teaserLimit |
||
124 | ); |
||
125 | $this->addSchemaOrgHeader($questions); |
||
126 | $this->view->assign('questions', $questions); |
||
127 | } |
||
128 | |||
129 | /** |
||
130 | * Render the detail action. |
||
131 | */ |
||
132 | public function detailAction(Question $question): void |
||
133 | { |
||
134 | $this->addSchemaOrgHeader([$question]); |
||
135 | $this->view->assign('question', $question); |
||
136 | } |
||
137 | |||
138 | /** |
||
139 | * Enter form. |
||
140 | * |
||
141 | * @IgnoreValidation(argumentName="question") |
||
142 | */ |
||
143 | public function formAction(QuestionRequest $question = null): void |
||
144 | { |
||
145 | if (null === $question) { |
||
146 | $question = new QuestionRequest(); |
||
147 | } |
||
148 | |||
149 | $this->view->assign('question', $question); |
||
150 | } |
||
151 | |||
152 | /** |
||
153 | * Send action. |
||
154 | * |
||
155 | * @throws StopActionException |
||
156 | */ |
||
157 | public function sendAction(QuestionRequest $question, string $captcha = null): void |
||
173 | |||
174 | /** |
||
175 | * user action. |
||
176 | * |
||
177 | * @throws StopActionException |
||
178 | */ |
||
179 | public function userAction(QuestionRequest $question): void |
||
191 | |||
192 | /** |
||
193 | * Send action. |
||
194 | */ |
||
195 | public function thanksAction(QuestionRequest $question): void |
||
200 | |||
201 | /** |
||
202 | * Get the target Email address. |
||
203 | * |
||
204 | * @throws \Exception |
||
205 | */ |
||
206 | protected function getTargetEmailAddress(): string |
||
213 | |||
214 | protected function addSchemaOrgHeader(iterable $questions): void |
||
215 | { |
||
216 | if (!$this->settings['faq']['addSchmemaOrgHeader']) { |
||
217 | return; |
||
255 | } |
||
256 |
This method has been deprecated. The supplier of the class has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.