Total Complexity | 66 |
Total Lines | 546 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
Complex classes like SelfServicePortalEntityManager often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use SelfServicePortalEntityManager, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
36 | class SelfServicePortalEntityManager extends AbstractEntityManager implements SelfServicePortalEntityManagerInterface |
||
37 | { |
||
38 | /** |
||
39 | * @param int $idProductConcrete |
||
40 | * @param int $idShipmentType |
||
41 | * |
||
42 | * @return void |
||
43 | */ |
||
44 | public function createProductShipmentType(int $idProductConcrete, int $idShipmentType): void |
||
53 | } |
||
54 | |||
55 | /** |
||
56 | * @param int $idProductConcrete |
||
57 | * @param list<int> $shipmentTypeIds |
||
58 | * |
||
59 | * @return void |
||
60 | */ |
||
61 | public function deleteProductShipmentTypesByIdProductConcreteAndShipmentTypeIds( |
||
62 | int $idProductConcrete, |
||
63 | array $shipmentTypeIds |
||
64 | ): void { |
||
65 | $this->getFactory() |
||
66 | ->createProductShipmentTypeQuery() |
||
67 | ->filterByFkProduct($idProductConcrete) |
||
68 | ->filterByFkShipmentType_In($shipmentTypeIds) |
||
69 | ->delete(); |
||
70 | } |
||
71 | |||
72 | /** |
||
73 | * @param int $idProductAbstract |
||
74 | * @param array<int> $productAbstractTypeIds |
||
75 | * |
||
76 | * @return void |
||
77 | */ |
||
78 | public function updateProductAbstractTypesForProductAbstract(int $idProductAbstract, array $productAbstractTypeIds): void |
||
79 | { |
||
80 | $this->deleteProductAbstractTypesByProductAbstractId($idProductAbstract); |
||
81 | |||
82 | foreach ($productAbstractTypeIds as $idProductAbstractType) { |
||
83 | $productAbstractToProductAbstractTypeEntity = new SpyProductAbstractToProductAbstractType(); |
||
84 | $productAbstractToProductAbstractTypeEntity |
||
85 | ->setFkProductAbstract($idProductAbstract) |
||
86 | ->setFkProductAbstractType($idProductAbstractType) |
||
87 | ->save(); |
||
88 | } |
||
89 | } |
||
90 | |||
91 | /** |
||
92 | * @param int $idProductAbstract |
||
93 | * |
||
94 | * @return void |
||
95 | */ |
||
96 | public function deleteProductAbstractTypesByProductAbstractId(int $idProductAbstract): void |
||
97 | { |
||
98 | /** |
||
99 | * @var \Propel\Runtime\Collection\ObjectCollection<\Orm\Zed\SelfServicePortal\Persistence\SpyProductAbstractToProductAbstractType> $productAbstractTypesProductAbstractRelations |
||
100 | */ |
||
101 | $productAbstractTypesProductAbstractRelations = $this->getFactory() |
||
102 | ->createProductAbstractToProductAbstractTypeQuery() |
||
103 | ->filterByFkProductAbstract($idProductAbstract) |
||
104 | ->find(); |
||
105 | |||
106 | $productAbstractTypesProductAbstractRelations->delete(); |
||
107 | } |
||
108 | |||
109 | /** |
||
110 | * @param int $idSalesOrderItem |
||
111 | * @param string $productTypeName |
||
112 | * |
||
113 | * @return void |
||
114 | */ |
||
115 | public function saveSalesOrderItemProductType(int $idSalesOrderItem, string $productTypeName): void |
||
116 | { |
||
117 | $salesProductAbstractTypeEntity = $this->getFactory() |
||
118 | ->createSalesProductAbstractTypeQuery() |
||
119 | ->filterByName($productTypeName) |
||
120 | ->findOneOrCreate(); |
||
121 | |||
122 | if ($salesProductAbstractTypeEntity->isNew()) { |
||
123 | $salesProductAbstractTypeEntity->save(); |
||
124 | } |
||
125 | |||
126 | $salesOrderItemProductAbstractTypeEntity = $this->getFactory() |
||
127 | ->createSalesOrderItemProductAbstractTypeQuery() |
||
128 | ->filterByFkSalesOrderItem($idSalesOrderItem) |
||
129 | ->filterByFkSalesProductAbstractType($salesProductAbstractTypeEntity->getIdSalesProductAbstractType()) |
||
130 | ->findOneOrCreate(); |
||
131 | |||
132 | if ($salesOrderItemProductAbstractTypeEntity->isNew()) { |
||
133 | $salesOrderItemProductAbstractTypeEntity->save(); |
||
134 | } |
||
135 | } |
||
136 | |||
137 | /** |
||
138 | * @param int $idSalesOrderItem |
||
139 | * @param bool $isServiceDateTimeEnabled |
||
140 | * |
||
141 | * @return void |
||
142 | */ |
||
143 | public function saveIsServiceDateTimeEnabledForSalesOrderItem(int $idSalesOrderItem, bool $isServiceDateTimeEnabled): void |
||
144 | { |
||
145 | $salesOrderItemEntity = $this->getFactory() |
||
146 | ->getSalesOrderItemPropelQuery() |
||
147 | ->filterByIdSalesOrderItem($idSalesOrderItem) |
||
148 | ->findOne(); |
||
149 | |||
150 | if ($salesOrderItemEntity) { |
||
151 | $salesOrderItemEntity->setIsServiceDateTimeEnabled($isServiceDateTimeEnabled); |
||
152 | $salesOrderItemEntity->save(); |
||
153 | } |
||
154 | } |
||
155 | |||
156 | /** |
||
157 | * @param \Generated\Shared\Transfer\FileAttachmentCollectionDeleteCriteriaTransfer $fileAttachmentCollectionDeleteCriteriaTransfer |
||
158 | * |
||
159 | * @throws \LogicException |
||
160 | * |
||
161 | * @return void |
||
162 | */ |
||
163 | public function deleteFileAttachmentCollection( |
||
164 | FileAttachmentCollectionDeleteCriteriaTransfer $fileAttachmentCollectionDeleteCriteriaTransfer |
||
165 | ): void { |
||
166 | /** @var list<\Orm\Zed\SelfServicePortal\Persistence\SpyCompanyFileQuery|\Orm\Zed\SelfServicePortal\Persistence\SpyCompanyUserFileQuery|\Orm\Zed\SelfServicePortal\Persistence\SpyCompanyBusinessUnitFileQuery> $fileAttachmentQueryList */ |
||
167 | $fileAttachmentQueryList = $this->getFactory()->getFileAttachmentQueryList(); |
||
168 | $isUnconditionalDeletion = true; |
||
169 | |||
170 | if ($fileAttachmentCollectionDeleteCriteriaTransfer->getCompanyIds() !== []) { |
||
171 | $isUnconditionalDeletion = false; |
||
172 | $fileAttachmentQueryList = $this->applyFileAttachmentByCompanyIdsCondition($fileAttachmentQueryList, $fileAttachmentCollectionDeleteCriteriaTransfer->getCompanyIds()); |
||
|
|||
173 | } |
||
174 | |||
175 | if ($fileAttachmentCollectionDeleteCriteriaTransfer->getCompanyUserIds() !== []) { |
||
176 | $isUnconditionalDeletion = false; |
||
177 | $fileAttachmentQueryList = $this->applyFileAttachmentByCompanyUserIdsCondition($fileAttachmentQueryList, $fileAttachmentCollectionDeleteCriteriaTransfer->getCompanyUserIds()); |
||
178 | } |
||
179 | |||
180 | if ($fileAttachmentCollectionDeleteCriteriaTransfer->getCompanyBusinessUnitIds() !== []) { |
||
181 | $isUnconditionalDeletion = false; |
||
182 | $fileAttachmentQueryList = $this->applyFileAttachmentByCompanyBusinessUnitIdsCondition($fileAttachmentQueryList, $fileAttachmentCollectionDeleteCriteriaTransfer->getCompanyBusinessUnitIds()); |
||
183 | } |
||
184 | |||
185 | if ($fileAttachmentCollectionDeleteCriteriaTransfer->getSspAssetIds() !== []) { |
||
186 | $isUnconditionalDeletion = false; |
||
187 | $fileAttachmentQueryList = $this->applyFileAttachmentByAssetIdsCondition($fileAttachmentQueryList, $fileAttachmentCollectionDeleteCriteriaTransfer->getSspAssetIds()); |
||
188 | } |
||
189 | |||
190 | if ($fileAttachmentCollectionDeleteCriteriaTransfer->getFileIds() !== []) { |
||
191 | $isUnconditionalDeletion = false; |
||
192 | $fileAttachmentQueryList = $this->applyFileAttachmentByFileIdsCondition( |
||
193 | $fileAttachmentQueryList, |
||
194 | $fileAttachmentCollectionDeleteCriteriaTransfer->getFileIds(), |
||
195 | count($fileAttachmentCollectionDeleteCriteriaTransfer->modifiedToArray()) > 1, |
||
196 | ); |
||
197 | } |
||
198 | |||
199 | if ($isUnconditionalDeletion && !$fileAttachmentCollectionDeleteCriteriaTransfer->getIsUnconditionalDeletionAllowed()) { |
||
200 | throw new LogicException('Unconditional deletion is not allowed.'); |
||
201 | } |
||
202 | |||
203 | $this->deleteFileAttachments($fileAttachmentQueryList); |
||
204 | } |
||
205 | |||
206 | /** |
||
207 | * @param list<\Orm\Zed\SelfServicePortal\Persistence\SpyCompanyFileQuery|\Orm\Zed\SelfServicePortal\Persistence\SpyCompanyUserFileQuery|\Orm\Zed\SelfServicePortal\Persistence\SpyCompanyBusinessUnitFileQuery|\Orm\Zed\SelfServicePortal\Persistence\SpySspAssetFileQuery> $fileAttachmentQueryList |
||
208 | * @param list<int> $fileIds |
||
209 | * @param bool $applyOnlyToModifiedQueries |
||
210 | * |
||
211 | * @return list<\Orm\Zed\SelfServicePortal\Persistence\SpyCompanyFileQuery|\Orm\Zed\SelfServicePortal\Persistence\SpyCompanyUserFileQuery|\Orm\Zed\SelfServicePortal\Persistence\SpyCompanyBusinessUnitFileQuery|\Orm\Zed\SelfServicePortal\Persistence\SpySspAssetFileQuery> |
||
212 | */ |
||
213 | protected function applyFileAttachmentByFileIdsCondition( |
||
214 | array $fileAttachmentQueryList, |
||
215 | array $fileIds, |
||
216 | bool $applyOnlyToModifiedQueries |
||
217 | ): array { |
||
218 | foreach ($fileAttachmentQueryList as $fileAttachmentQuery) { |
||
219 | if ($applyOnlyToModifiedQueries && !$fileAttachmentQuery->hasWhereClause()) { |
||
220 | continue; |
||
221 | } |
||
222 | |||
223 | $fileAttachmentQuery->filterByFkFile_In($fileIds); |
||
224 | } |
||
225 | |||
226 | return $fileAttachmentQueryList; |
||
227 | } |
||
228 | |||
229 | /** |
||
230 | * @param list<\Orm\Zed\SelfServicePortal\Persistence\SpyCompanyFileQuery|\Orm\Zed\SelfServicePortal\Persistence\SpyCompanyUserFileQuery|\Orm\Zed\SelfServicePortal\Persistence\SpyCompanyBusinessUnitFileQuery> $fileAttachmentQueryList |
||
231 | * @param list<int> $companyIds |
||
232 | * |
||
233 | * @return list<\Orm\Zed\SelfServicePortal\Persistence\SpyCompanyFileQuery|\Orm\Zed\SelfServicePortal\Persistence\SpyCompanyUserFileQuery|\Orm\Zed\SelfServicePortal\Persistence\SpyCompanyBusinessUnitFileQuery> |
||
234 | */ |
||
235 | protected function applyFileAttachmentByCompanyIdsCondition( |
||
236 | array $fileAttachmentQueryList, |
||
237 | array $companyIds |
||
238 | ): array { |
||
239 | foreach ($fileAttachmentQueryList as $fileAttachmentQuery) { |
||
240 | if ($fileAttachmentQuery instanceof SpyCompanyFileQuery) { |
||
241 | $fileAttachmentQuery->filterByFkCompany_In($companyIds); |
||
242 | } |
||
243 | } |
||
244 | |||
245 | return $fileAttachmentQueryList; |
||
246 | } |
||
247 | |||
248 | /** |
||
249 | * @param list<\Orm\Zed\SelfServicePortal\Persistence\SpyCompanyFileQuery|\Orm\Zed\SelfServicePortal\Persistence\SpyCompanyUserFileQuery|\Orm\Zed\SelfServicePortal\Persistence\SpyCompanyBusinessUnitFileQuery> $fileAttachmentQueryList |
||
250 | * @param list<int> $companyUserIds |
||
251 | * |
||
252 | * @return list<\Orm\Zed\SelfServicePortal\Persistence\SpyCompanyFileQuery|\Orm\Zed\SelfServicePortal\Persistence\SpyCompanyUserFileQuery|\Orm\Zed\SelfServicePortal\Persistence\SpyCompanyBusinessUnitFileQuery> |
||
253 | */ |
||
254 | protected function applyFileAttachmentByCompanyUserIdsCondition( |
||
255 | array $fileAttachmentQueryList, |
||
256 | array $companyUserIds |
||
257 | ): array { |
||
258 | foreach ($fileAttachmentQueryList as $fileAttachmentQuery) { |
||
259 | if ($fileAttachmentQuery instanceof SpyCompanyUserFileQuery) { |
||
260 | $fileAttachmentQuery->filterByFkCompanyUser_In($companyUserIds); |
||
261 | } |
||
262 | } |
||
263 | |||
264 | return $fileAttachmentQueryList; |
||
265 | } |
||
266 | |||
267 | /** |
||
268 | * @param list<\Orm\Zed\SelfServicePortal\Persistence\SpyCompanyFileQuery|\Orm\Zed\SelfServicePortal\Persistence\SpyCompanyUserFileQuery|\Orm\Zed\SelfServicePortal\Persistence\SpyCompanyBusinessUnitFileQuery> $fileAttachmentQueryList |
||
269 | * @param list<int> $companyBusinessUnitIds |
||
270 | * |
||
271 | * @return list<\Orm\Zed\SelfServicePortal\Persistence\SpyCompanyFileQuery|\Orm\Zed\SelfServicePortal\Persistence\SpyCompanyUserFileQuery|\Orm\Zed\SelfServicePortal\Persistence\SpyCompanyBusinessUnitFileQuery> |
||
272 | */ |
||
273 | protected function applyFileAttachmentByCompanyBusinessUnitIdsCondition( |
||
274 | array $fileAttachmentQueryList, |
||
275 | array $companyBusinessUnitIds |
||
276 | ): array { |
||
277 | foreach ($fileAttachmentQueryList as $fileAttachmentQuery) { |
||
278 | if ($fileAttachmentQuery instanceof SpyCompanyBusinessUnitFileQuery) { |
||
279 | $fileAttachmentQuery->filterByFkCompanyBusinessUnit_In($companyBusinessUnitIds); |
||
280 | } |
||
281 | } |
||
282 | |||
283 | return $fileAttachmentQueryList; |
||
284 | } |
||
285 | |||
286 | /** |
||
287 | * @param list<\Orm\Zed\SelfServicePortal\Persistence\SpyCompanyFileQuery|\Orm\Zed\SelfServicePortal\Persistence\SpyCompanyUserFileQuery|\Orm\Zed\SelfServicePortal\Persistence\SpyCompanyBusinessUnitFileQuery|\Orm\Zed\SelfServicePortal\Persistence\SpySspAssetFileQuery> $fileAttachmentQueryList |
||
288 | * @param list<int> $assetIds |
||
289 | * |
||
290 | * @return list<\Orm\Zed\SelfServicePortal\Persistence\SpyCompanyFileQuery|\Orm\Zed\SelfServicePortal\Persistence\SpyCompanyUserFileQuery|\Orm\Zed\SelfServicePortal\Persistence\SpyCompanyBusinessUnitFileQuery|\Orm\Zed\SelfServicePortal\Persistence\SpySspAssetFileQuery> |
||
291 | */ |
||
292 | protected function applyFileAttachmentByAssetIdsCondition( |
||
293 | array $fileAttachmentQueryList, |
||
294 | array $assetIds |
||
295 | ): array { |
||
296 | foreach ($fileAttachmentQueryList as $fileAttachmentQuery) { |
||
297 | if ($fileAttachmentQuery instanceof SpySspAssetFileQuery) { |
||
298 | $fileAttachmentQuery->filterByFkSspAsset_In($assetIds); |
||
299 | } |
||
300 | } |
||
301 | |||
302 | return $fileAttachmentQueryList; |
||
303 | } |
||
304 | |||
305 | /** |
||
306 | * @param list<\Orm\Zed\SelfServicePortal\Persistence\SpyCompanyFileQuery|\Orm\Zed\SelfServicePortal\Persistence\SpyCompanyUserFileQuery|\Orm\Zed\SelfServicePortal\Persistence\SpyCompanyBusinessUnitFileQuery|\Orm\Zed\SelfServicePortal\Persistence\SpySspAssetFileQuery> $fileAttachmentQueryList |
||
307 | * |
||
308 | * @return void |
||
309 | */ |
||
310 | protected function deleteFileAttachments(array $fileAttachmentQueryList): void |
||
311 | { |
||
312 | foreach ($fileAttachmentQueryList as $fileAttachmentQuery) { |
||
313 | if (!$fileAttachmentQuery->hasWhereClause()) { |
||
314 | continue; |
||
315 | } |
||
316 | |||
317 | $fileAttachmentQuery->delete(); |
||
318 | } |
||
319 | } |
||
320 | |||
321 | /** |
||
322 | * @param \Generated\Shared\Transfer\FileAttachmentTransfer $fileAttachmentTransfer |
||
323 | * |
||
324 | * @throws \LogicException |
||
325 | * |
||
326 | * @return \Generated\Shared\Transfer\FileAttachmentTransfer |
||
327 | */ |
||
328 | public function saveFileAttachment(FileAttachmentTransfer $fileAttachmentTransfer): FileAttachmentTransfer |
||
329 | { |
||
330 | $fileAttachmentSaver = null; |
||
331 | |||
332 | foreach ($this->getFactory()->createFileAttachmentSavers() as $fileAttachmentSaverOption) { |
||
333 | if ($fileAttachmentSaverOption->isApplicable($fileAttachmentTransfer)) { |
||
334 | $fileAttachmentSaver = $fileAttachmentSaverOption; |
||
335 | } |
||
336 | } |
||
337 | |||
338 | if (!$fileAttachmentSaver) { |
||
339 | throw new LogicException(sprintf('Saver for entity "%s" is not implemented.', $fileAttachmentTransfer->getEntityName())); |
||
340 | } |
||
341 | |||
342 | return $fileAttachmentSaver->save($fileAttachmentTransfer); |
||
343 | } |
||
344 | |||
345 | /** |
||
346 | * @param \Generated\Shared\Transfer\SspInquiryTransfer $sspInquiryTransfer |
||
347 | * |
||
348 | * @return \Generated\Shared\Transfer\SspInquiryTransfer |
||
349 | */ |
||
350 | public function createSspInquiry(SspInquiryTransfer $sspInquiryTransfer): SspInquiryTransfer |
||
351 | { |
||
352 | return $this->saveSspInquiry($sspInquiryTransfer, new SpySspInquiry()); |
||
353 | } |
||
354 | |||
355 | /** |
||
356 | * @param \Generated\Shared\Transfer\SspInquiryTransfer $sspInquiryTransfer |
||
357 | * |
||
358 | * @return \Generated\Shared\Transfer\SspInquiryTransfer|null |
||
359 | */ |
||
360 | public function updateSspInquiry(SspInquiryTransfer $sspInquiryTransfer): ?SspInquiryTransfer |
||
361 | { |
||
362 | $sspInquiryQuery = $this->getFactory()->createSspInquiryQuery(); |
||
363 | |||
364 | $sspInquiryEntity = $sspInquiryQuery->filterByIdSspInquiry($sspInquiryTransfer->getIdSspInquiry())->findOne(); |
||
365 | |||
366 | if (!$sspInquiryEntity) { |
||
367 | return null; |
||
368 | } |
||
369 | |||
370 | return $this->saveSspInquiry($sspInquiryTransfer, $sspInquiryEntity); |
||
371 | } |
||
372 | |||
373 | /** |
||
374 | * @param \Generated\Shared\Transfer\SspInquiryTransfer $sspInquiryTransfer |
||
375 | * @param \Orm\Zed\SelfServicePortal\Persistence\SpySspInquiry $sspInquiryEntity |
||
376 | * |
||
377 | * @return \Generated\Shared\Transfer\SspInquiryTransfer |
||
378 | */ |
||
379 | protected function saveSspInquiry(SspInquiryTransfer $sspInquiryTransfer, SpySspInquiry $sspInquiryEntity): SspInquiryTransfer |
||
380 | { |
||
381 | $sspInquiryEntity = $this->getFactory()->createSspInquiryMapper()->mapSspInquiryTransferToSspInquiryEntity($sspInquiryTransfer, $sspInquiryEntity); |
||
382 | |||
383 | if ($sspInquiryTransfer->getStatus()) { |
||
384 | $stateMachineItemState = $this->getFactory()->getStateMachineItemStatePropelQuery()->findOneByName($sspInquiryTransfer->getStatus()); |
||
385 | if ($stateMachineItemState) { |
||
386 | $sspInquiryEntity->setFkStateMachineItemState($stateMachineItemState->getIdStateMachineItemState()); |
||
387 | } |
||
388 | } |
||
389 | |||
390 | if ($sspInquiryEntity->isNew() || $sspInquiryEntity->isModified()) { |
||
391 | $sspInquiryEntity->save(); |
||
392 | } |
||
393 | |||
394 | $sspInquiryTransfer = $this->getFactory()->createSspInquiryMapper()->mapSspInquiryEntityToSspInquiryTransfer($sspInquiryEntity, $sspInquiryTransfer); |
||
395 | |||
396 | return $sspInquiryTransfer; |
||
397 | } |
||
398 | |||
399 | /** |
||
400 | * @param \Generated\Shared\Transfer\SspInquiryTransfer $sspInquiryTransfer |
||
401 | * |
||
402 | * @return \Generated\Shared\Transfer\SspInquiryTransfer |
||
403 | */ |
||
404 | public function createSspInquiryFiles(SspInquiryTransfer $sspInquiryTransfer): SspInquiryTransfer |
||
405 | { |
||
406 | foreach ($sspInquiryTransfer->getFiles() as $fileTransfer) { |
||
407 | $sspInquiryFileEntity = (new SpySspInquiryFile()) |
||
408 | ->setFkFile($fileTransfer->getIdFileOrFail()) |
||
409 | ->setFkSspInquiry($sspInquiryTransfer->getIdSspInquiryOrFail()); |
||
410 | |||
411 | $sspInquiryFileEntity->save(); |
||
412 | } |
||
413 | |||
414 | return $sspInquiryTransfer; |
||
415 | } |
||
416 | |||
417 | /** |
||
418 | * @param \Generated\Shared\Transfer\SspInquiryTransfer $sspInquiryTransfer |
||
419 | * |
||
420 | * @return \Generated\Shared\Transfer\SspInquiryTransfer |
||
421 | */ |
||
422 | public function createSspInquirySalesOrder(SspInquiryTransfer $sspInquiryTransfer): SspInquiryTransfer |
||
423 | { |
||
424 | $sspInquirySalesOrderEntity = (new SpySspInquirySalesOrder()) |
||
425 | ->setFkSspInquiry($sspInquiryTransfer->getIdSspInquiryOrFail()) |
||
426 | ->setFkSalesOrder($sspInquiryTransfer->getOrderOrFail()->getIdSalesOrderOrFail()); |
||
427 | |||
428 | $sspInquirySalesOrderEntity->save(); |
||
429 | |||
430 | return $sspInquiryTransfer; |
||
431 | } |
||
432 | |||
433 | /** |
||
434 | * @param \Generated\Shared\Transfer\SspInquiryTransfer $sspInquiryTransfer |
||
435 | * |
||
436 | * @return \Generated\Shared\Transfer\SspInquiryTransfer |
||
437 | */ |
||
438 | public function createSspInquirySspAsset(SspInquiryTransfer $sspInquiryTransfer): SspInquiryTransfer |
||
439 | { |
||
440 | $sspInquirySspAssetEntity = (new SpySspInquirySspAsset()) |
||
441 | ->setFkSspInquiry($sspInquiryTransfer->getIdSspInquiryOrFail()) |
||
442 | ->setFkSspAsset($sspInquiryTransfer->getSspAssetOrFail()->getIdSspAssetOrFail()); |
||
443 | |||
444 | $sspInquirySspAssetEntity->save(); |
||
445 | |||
446 | return $sspInquiryTransfer; |
||
447 | } |
||
448 | |||
449 | /** |
||
450 | * @param \Generated\Shared\Transfer\FileCollectionTransfer $fileCollectionTransfer |
||
451 | * |
||
452 | * @return void |
||
453 | */ |
||
454 | public function deleteSspInquiryFileRelation(FileCollectionTransfer $fileCollectionTransfer): void |
||
455 | { |
||
456 | $fileIds = []; |
||
457 | |||
458 | foreach ($fileCollectionTransfer->getFiles() as $fileTransfer) { |
||
459 | $fileIds[] = $fileTransfer->getIdFileOrFail(); |
||
460 | } |
||
461 | |||
462 | if (!$fileIds) { |
||
463 | return; |
||
464 | } |
||
465 | |||
466 | $this->getFactory()->createSspInquiryFileQuery()->filterByFkFile_In($fileIds)->delete(); |
||
467 | } |
||
468 | |||
469 | /** |
||
470 | * @param \Generated\Shared\Transfer\SspAssetTransfer $sspAssetTransfer |
||
471 | * |
||
472 | * @return \Generated\Shared\Transfer\SspAssetTransfer |
||
473 | */ |
||
474 | public function createSspAsset(SspAssetTransfer $sspAssetTransfer): SspAssetTransfer |
||
475 | { |
||
476 | $spySspAssetEntity = $this->getFactory() |
||
477 | ->createAssetMapper() |
||
478 | ->mapSspAssetTransferToSpySspAssetEntity($sspAssetTransfer, new SpySspAsset()); |
||
479 | |||
480 | $spySspAssetEntity->save(); |
||
481 | $sspAssetTransfer->setIdSspAsset($spySspAssetEntity->getIdSspAsset()); |
||
482 | |||
483 | return $this->getFactory() |
||
484 | ->createAssetMapper() |
||
485 | ->mapSpySspAssetEntityToSspAssetTransfer($spySspAssetEntity, $sspAssetTransfer); |
||
486 | } |
||
487 | |||
488 | /** |
||
489 | * @param \Generated\Shared\Transfer\SspAssetTransfer $sspAssetTransfer |
||
490 | * |
||
491 | * @throws \Propel\Runtime\Exception\InvalidArgumentException |
||
492 | * |
||
493 | * @return \Generated\Shared\Transfer\SspAssetTransfer |
||
494 | */ |
||
495 | public function updateSspAsset(SspAssetTransfer $sspAssetTransfer): SspAssetTransfer |
||
496 | { |
||
497 | $spySspAssetEntity = $this->getFactory() |
||
498 | ->createSspAssetQuery() |
||
499 | ->findOneByIdSspAsset($sspAssetTransfer->getIdSspAssetOrFail()); |
||
500 | |||
501 | if (!$spySspAssetEntity) { |
||
502 | throw new InvalidArgumentException('Ssp Asset not found'); |
||
503 | } |
||
504 | |||
505 | $spySspAssetEntity = $this->getFactory() |
||
506 | ->createAssetMapper() |
||
507 | ->mapSspAssetTransferToSpySspAssetEntity($sspAssetTransfer, $spySspAssetEntity); |
||
508 | |||
509 | if ($spySspAssetEntity->isModified()) { |
||
510 | $spySspAssetEntity->save(); |
||
511 | } |
||
512 | |||
513 | return $this->getFactory() |
||
514 | ->createAssetMapper() |
||
515 | ->mapSpySspAssetEntityToSspAssetTransfer($spySspAssetEntity, $sspAssetTransfer); |
||
516 | } |
||
517 | |||
518 | /** |
||
519 | * @param \Generated\Shared\Transfer\SalesOrderItemSspAssetTransfer $salesOrderItemSspAssetTransfer |
||
520 | * |
||
521 | * @return void |
||
522 | */ |
||
523 | public function createSalesOrderItemSspAsset(SalesOrderItemSspAssetTransfer $salesOrderItemSspAssetTransfer): void |
||
524 | { |
||
525 | $salesOrderItemSspAssetEntity = new SpySalesOrderItemSspAsset(); |
||
526 | $salesOrderItemSspAssetEntity->fromArray($salesOrderItemSspAssetTransfer->toArray()); |
||
527 | $salesOrderItemSspAssetEntity->setFkSalesOrderItem($salesOrderItemSspAssetTransfer->getSalesOrderItemOrFail()->getIdSalesOrderItemOrFail()); |
||
528 | $salesOrderItemSspAssetEntity->save(); |
||
529 | } |
||
530 | |||
531 | /** |
||
532 | * @param int $idSspAsset |
||
533 | * @param array<int> $businessUnitIds |
||
534 | * |
||
535 | * @return void |
||
536 | */ |
||
537 | public function deleteAssetToCompanyBusinessUnitRelations(int $idSspAsset, array $businessUnitIds): void |
||
538 | { |
||
539 | SpySspAssetToCompanyBusinessUnitQuery::create() |
||
540 | ->filterByFkSspAsset($idSspAsset) |
||
541 | ->filterByFkCompanyBusinessUnit_In($businessUnitIds) |
||
542 | ->delete(); |
||
543 | } |
||
544 | |||
545 | /** |
||
546 | * @param int $idSspAsset |
||
547 | * @param array<int> $businessUnitIds |
||
548 | * |
||
549 | * @return void |
||
550 | */ |
||
551 | public function createAssetToCompanyBusinessUnitRelation(int $idSspAsset, array $businessUnitIds): void |
||
559 | } |
||
560 | } |
||
561 | |||
562 | /** |
||
563 | * @param array<int> $salesOrderItemIds |
||
564 | * |
||
565 | * @return void |
||
566 | */ |
||
567 | public function deleteSalesOrderItemProductAbstractTypesBySalesOrderItemIds(array $salesOrderItemIds): void |
||
568 | { |
||
569 | if (!$salesOrderItemIds) { |
||
570 | return; |
||
571 | } |
||
572 | |||
573 | /** |
||
574 | * @var \Propel\Runtime\Collection\ObjectCollection $salesOrderItemProductAbstractTypeEntityCollection |
||
575 | */ |
||
576 | $salesOrderItemProductAbstractTypeEntityCollection = $this->getFactory() |
||
582 | } |
||
583 | } |
||
584 |