1 | <?php |
||
23 | class ExportService |
||
24 | { |
||
25 | /** |
||
26 | * Repository with registrations for the events |
||
27 | * |
||
28 | * @var \DERHANSEN\SfEventMgt\Domain\Repository\RegistrationRepository |
||
29 | */ |
||
30 | protected $registrationRepository; |
||
31 | |||
32 | /** |
||
33 | * ResourceFactory |
||
34 | * |
||
35 | * @var \TYPO3\CMS\Core\Resource\ResourceFactory |
||
36 | */ |
||
37 | protected $resourceFactory = null; |
||
38 | |||
39 | /** |
||
40 | * DI for $registrationRepository |
||
41 | * |
||
42 | * @param RegistrationRepository $registrationRepository |
||
43 | */ |
||
44 | public function injectRegistrationRepository( |
||
49 | |||
50 | /** |
||
51 | * DI for $resourceFactory |
||
52 | * |
||
53 | 4 | * @param ResourceFactory $resourceFactory |
|
54 | */ |
||
55 | 4 | public function injectResourceFactory(\TYPO3\CMS\Core\Resource\ResourceFactory $resourceFactory) |
|
59 | 2 | ||
60 | 2 | /** |
|
61 | 2 | * Initiates the CSV downloads for registrations of the given event uid |
|
62 | 2 | * |
|
63 | 2 | * @param int $eventUid EventUid |
|
64 | 2 | * @param array $settings Settings |
|
65 | 2 | * @throws Exception RuntimeException |
|
66 | * @return void |
||
67 | */ |
||
68 | public function downloadRegistrationsCsv($eventUid, $settings = []) |
||
81 | 10 | ||
82 | 10 | /** |
|
83 | 10 | * Returns, if the user has read/write access permissions to the __temp__ folder |
|
84 | 10 | * |
|
85 | 10 | * @return bool |
|
86 | 10 | */ |
|
87 | 10 | public function hasWriteAccessToTempFolder() |
|
88 | 2 | { |
|
89 | 2 | $result = true; |
|
90 | $storage = $this->resourceFactory->getDefaultStorage(); |
||
91 | 10 | if ($storage === null) { |
|
92 | 8 | return false; |
|
93 | 8 | } |
|
94 | 8 | ||
95 | 8 | try { |
|
96 | /** @var Folder $folder */ |
||
97 | $folder = $storage->getFolder('_temp_'); |
||
98 | if (!$folder->checkActionPermission('write')) { |
||
99 | $result = false; |
||
100 | } |
||
101 | } catch (\Exception $e) { |
||
102 | $result = false; |
||
103 | } |
||
104 | |||
105 | return $result; |
||
106 | 10 | } |
|
107 | |||
108 | 10 | /** |
|
109 | 10 | * Returns all Registrations for the given eventUid as a CSV string |
|
110 | * |
||
111 | * @param int $eventUid EventUid |
||
112 | 10 | * @param array $settings Settings |
|
113 | * @throws Exception RuntimeException |
||
114 | * @return string |
||
115 | */ |
||
116 | public function exportRegistrationsCsv($eventUid, $settings = []) |
||
145 | |||
146 | /** |
||
147 | * Prepends Byte Order Mark to exported registrations |
||
148 | * |
||
149 | * @param string $exportedRegistrations |
||
150 | * @param array $settings |
||
151 | * @return string |
||
152 | */ |
||
153 | protected function prependByteOrderMark($exportedRegistrations, $settings) |
||
161 | |||
162 | /** |
||
163 | * Returns the requested field from the given registration. If the field is a DateTime object, |
||
164 | * a formatted date string is returned |
||
165 | * |
||
166 | * @param \DERHANSEN\SfEventMgt\Domain\Model\Registration $registration |
||
167 | * @param string $field |
||
168 | * @return string |
||
169 | */ |
||
170 | protected function getFieldValue($registration, $field) |
||
179 | } |
||
180 |
If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:
If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.