| Total Complexity | 70 |
| Total Lines | 602 |
| Duplicated Lines | 0 % |
| Changes | 6 | ||
| Bugs | 1 | Features | 0 |
Complex classes like DocumentFormBackofficeController 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 DocumentFormBackofficeController, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 33 | class DocumentFormBackofficeController extends AbstractDocumentFormController |
||
| 34 | { |
||
| 35 | /** |
||
| 36 | * documentTransferManager |
||
| 37 | * |
||
| 38 | * @var \EWW\Dpf\Services\Transfer\DocumentTransferManager $documentTransferManager |
||
| 39 | */ |
||
| 40 | protected $documentTransferManager; |
||
| 41 | |||
| 42 | /** |
||
| 43 | * fedoraRepository |
||
| 44 | * |
||
| 45 | * @var \EWW\Dpf\Services\Transfer\FedoraRepository $fedoraRepository |
||
| 46 | */ |
||
| 47 | protected $fedoraRepository; |
||
| 48 | |||
| 49 | /** |
||
| 50 | * editingLockService |
||
| 51 | * |
||
| 52 | * @var \EWW\Dpf\Services\Document\EditingLockService |
||
| 53 | * @TYPO3\CMS\Extbase\Annotation\Inject |
||
| 54 | */ |
||
| 55 | protected $editingLockService = null; |
||
| 56 | |||
| 57 | /** |
||
| 58 | * documentManager |
||
| 59 | * |
||
| 60 | * @var \EWW\Dpf\Services\Document\DocumentManager |
||
| 61 | * @TYPO3\CMS\Extbase\Annotation\Inject |
||
| 62 | */ |
||
| 63 | protected $documentManager = null; |
||
| 64 | |||
| 65 | /** |
||
| 66 | * bookmarkRepository |
||
| 67 | * |
||
| 68 | * @var \EWW\Dpf\Domain\Repository\BookmarkRepository |
||
| 69 | * @TYPO3\CMS\Extbase\Annotation\Inject |
||
| 70 | */ |
||
| 71 | protected $bookmarkRepository = null; |
||
| 72 | |||
| 73 | /** |
||
| 74 | * clientConfigurationManager |
||
| 75 | * |
||
| 76 | * @var \EWW\Dpf\Configuration\ClientConfigurationManager |
||
| 77 | * @TYPO3\CMS\Extbase\Annotation\Inject |
||
| 78 | */ |
||
| 79 | protected $clientConfigurationManager; |
||
| 80 | |||
| 81 | /** |
||
| 82 | * DocumentController constructor. |
||
| 83 | */ |
||
| 84 | public function __construct() |
||
| 85 | { |
||
| 86 | parent::__construct(); |
||
| 87 | |||
| 88 | $objectManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\Object\ObjectManager::class); |
||
| 89 | $this->documentTransferManager = $objectManager->get(DocumentTransferManager::class); |
||
| 90 | $this->fedoraRepository = $objectManager->get(FedoraRepository::class); |
||
| 91 | $this->documentTransferManager->setRemoteRepository($this->fedoraRepository); |
||
| 92 | } |
||
| 93 | |||
| 94 | public function arrayRecursiveDiff($aArray1, $aArray2) { |
||
| 95 | $aReturn = array(); |
||
| 96 | |||
| 97 | foreach ($aArray1 as $mKey => $mValue) { |
||
| 98 | if (array_key_exists($mKey, $aArray2)) { |
||
| 99 | if (is_array($mValue)) { |
||
| 100 | $aRecursiveDiff = $this->arrayRecursiveDiff($mValue, $aArray2[$mKey]); |
||
| 101 | if (count($aRecursiveDiff)) { $aReturn[$mKey] = $aRecursiveDiff; } |
||
| 102 | } else { |
||
| 103 | if ($mValue != $aArray2[$mKey]) { |
||
| 104 | $aReturn[$mKey] = $mValue; |
||
| 105 | } |
||
| 106 | } |
||
| 107 | } else { |
||
| 108 | $aReturn[$mKey] = $mValue; |
||
| 109 | } |
||
| 110 | } |
||
| 111 | return $aReturn; |
||
| 112 | } |
||
| 113 | |||
| 114 | |||
| 115 | /** |
||
| 116 | * action edit |
||
| 117 | * |
||
| 118 | * @param \EWW\Dpf\Domain\Model\DocumentForm $documentForm |
||
| 119 | * @param bool $suggestMod |
||
| 120 | * @param string activeGroup |
||
| 121 | * @param int activeGroupIndex |
||
| 122 | * @param bool $addCurrentFeUser |
||
| 123 | * @TYPO3\CMS\Extbase\Annotation\IgnoreValidation("documentForm") |
||
| 124 | * @return void |
||
| 125 | */ |
||
| 126 | public function editAction( |
||
| 176 | } |
||
| 177 | |||
| 178 | /** |
||
| 179 | * @param \EWW\Dpf\Domain\Model\DocumentForm $documentForm |
||
| 180 | * @param bool $restore |
||
| 181 | */ |
||
| 182 | public function createSuggestionDocumentAction(\EWW\Dpf\Domain\Model\DocumentForm $documentForm, $restore = FALSE) |
||
| 183 | { |
||
| 184 | $documentMapper = $this->objectManager->get(DocumentMapper::class); |
||
| 185 | |||
| 186 | $workingCopy = $this->documentRepository->findByUid($documentForm->getDocumentUid()); |
||
| 187 | |||
| 188 | if ($workingCopy->isTemporary()) { |
||
| 189 | $workingCopy->setTemporary(false); |
||
| 190 | } |
||
| 191 | |||
| 192 | $newDocument = $this->objectManager->get(Document::class); |
||
| 193 | |||
| 194 | $this->documentRepository->add($newDocument); |
||
| 195 | $this->persistenceManager->persistAll(); |
||
| 196 | |||
| 197 | /* @var $document \EWW\Dpf\Domain\Model\Document */ |
||
| 198 | $document = $documentMapper->getDocument($documentForm); |
||
| 199 | |||
| 200 | /* @var $newDocument \EWW\Dpf\Domain\Model\Document */ |
||
| 201 | $newDocument = $newDocument->copy($document); |
||
| 202 | |||
| 203 | if ($document->getObjectIdentifier()) { |
||
| 204 | $newDocument->setLinkedUid($document->getObjectIdentifier()); |
||
| 205 | } else { |
||
| 206 | $newDocument->setLinkedUid($document->getUid()); |
||
| 207 | } |
||
| 208 | |||
| 209 | $newDocument->setSuggestion(true); |
||
| 210 | $newDocument->setComment($document->getComment()); |
||
| 211 | |||
| 212 | if ($restore) { |
||
| 213 | $newDocument->setTransferStatus("RESTORE"); |
||
| 214 | } |
||
| 215 | |||
| 216 | if ($workingCopy->hasFiles()) { |
||
| 217 | // Add or update files |
||
| 218 | // TODO: Is this still necessary? |
||
| 219 | foreach ($documentForm->getFiles() as $file) { |
||
| 220 | // TODO: Is this still necessary? |
||
| 221 | if ($file->getUID()) { |
||
| 222 | $this->fileRepository->update($file); |
||
| 223 | } else { |
||
| 224 | $file->setDocument($newDocument); |
||
| 225 | $this->fileRepository->add($file); |
||
| 226 | } |
||
| 227 | |||
| 228 | $newDocument->addFile($file); |
||
| 229 | } |
||
| 230 | } else { |
||
| 231 | // remove files for suggest object |
||
| 232 | $newDocument->setFile($this->objectManager->get(ObjectStorage::class)); |
||
| 233 | } |
||
| 234 | |||
| 235 | |||
| 236 | try { |
||
| 237 | $newDocument->setCreator($this->security->getUser()->getUid()); |
||
| 238 | $this->documentRepository->add($newDocument); |
||
| 239 | |||
| 240 | $flashMessage = $this->clientConfigurationManager->getSuggestionFlashMessage(); |
||
| 241 | if (!$flashMessage) { |
||
| 242 | $flashMessage = LocalizationUtility::translate( |
||
| 243 | 'LLL:EXT:dpf/Resources/Private/Language/locallang.xlf:message.suggestion_flashmessage', |
||
| 244 | 'dpf', |
||
| 245 | '' |
||
| 246 | ); |
||
| 247 | } |
||
| 248 | $this->addFlashMessage($flashMessage, '', AbstractMessage::OK, true); |
||
| 249 | |||
| 250 | $notifier = $this->objectManager->get(Notifier::class); |
||
| 251 | $notifier->sendAdminNewSuggestionNotification($newDocument); |
||
| 252 | |||
| 253 | $depositLicenseLog = $this->depositLicenseLogRepository->findOneByProcessNumber($newDocument->getProcessNumber()); |
||
| 254 | if (empty($depositLicenseLog) && $newDocument->getDepositLicense()) { |
||
| 255 | // Only if there was no deposit license a notification may be sent |
||
| 256 | |||
| 257 | /** @var DepositLicenseLog $depositLicenseLog */ |
||
| 258 | $depositLicenseLog = $this->objectManager->get(DepositLicenseLog::class); |
||
| 259 | $depositLicenseLog->setUsername($this->security->getUsername()); |
||
| 260 | $depositLicenseLog->setObjectIdentifier($newDocument->getObjectIdentifier()); |
||
| 261 | $depositLicenseLog->setProcessNumber($newDocument->getProcessNumber()); |
||
| 262 | $depositLicenseLog->setTitle($newDocument->getTitle()); |
||
| 263 | $depositLicenseLog->setUrn($newDocument->getPrimaryUrn()); |
||
| 264 | $depositLicenseLog->setLicenceUri($newDocument->getDepositLicense()); |
||
| 265 | |||
| 266 | if ($newDocument->hasFiles()) { |
||
| 267 | $fileList = []; |
||
| 268 | foreach ($newDocument->getFile() as $file) { |
||
| 269 | $fileList[] = $file->getTitle(); |
||
| 270 | } |
||
| 271 | $depositLicenseLog->setFileNames(implode(", ", $fileList)); |
||
| 272 | } |
||
| 273 | |||
| 274 | |||
| 275 | $this->depositLicenseLogRepository->add($depositLicenseLog); |
||
| 276 | |||
| 277 | /** @var Notifier $notifier */ |
||
| 278 | $notifier = $this->objectManager->get(Notifier::class); |
||
| 279 | $notifier->sendDepositLicenseNotification($newDocument); |
||
| 280 | } |
||
| 281 | |||
| 282 | } catch (\Throwable $t) { |
||
| 283 | $severity = \TYPO3\CMS\Core\Messaging\AbstractMessage::ERROR; |
||
| 284 | $this->addFlashMessage("Failed", '', $severity,false); |
||
| 285 | } |
||
| 286 | |||
| 287 | $this->redirectToDocumentList(); |
||
| 288 | } |
||
| 289 | |||
| 290 | |||
| 291 | public function updateAction(\EWW\Dpf\Domain\Model\DocumentForm $documentForm) |
||
| 292 | { |
||
| 293 | if ($this->request->getArgument('documentData')['suggestMod']) { |
||
| 294 | $restore = $this->request->getArgument('documentData')['suggestRestore']; |
||
| 295 | $this->forward('createSuggestionDocument', null, null, ['documentForm' => $documentForm, 'restore' => $restore]); |
||
| 296 | } |
||
| 297 | |||
| 298 | $backToList = $this->request->getArgument('documentData')['backToList']; |
||
| 299 | |||
| 300 | if ($this->request->hasArgument('saveAndUpdate')) { |
||
| 301 | $saveMode = 'saveAndUpdate'; |
||
| 302 | } elseif ($this->request->hasArgument('saveWorkingCopy')) { |
||
| 303 | $saveMode = 'saveWorkingCopy'; |
||
| 304 | } else { |
||
| 305 | $saveMode = null; |
||
| 306 | } |
||
| 307 | |||
| 308 | $this->forward( |
||
| 309 | |||
| 310 | 'updateDocument', |
||
| 311 | NULL, |
||
| 312 | NULL, |
||
| 313 | [ |
||
| 314 | 'documentForm' => $documentForm, |
||
| 315 | 'saveMode' => $saveMode, |
||
| 316 | 'backToList' => $backToList |
||
| 317 | ] |
||
| 318 | ); |
||
| 319 | } |
||
| 320 | |||
| 321 | |||
| 322 | /** |
||
| 323 | * @param \EWW\Dpf\Domain\Model\DocumentForm $documentForm |
||
| 324 | * @param string $saveMode |
||
| 325 | * @param bool $backToList |
||
| 326 | * @throws \TYPO3\CMS\Extbase\Mvc\Exception\StopActionException |
||
| 327 | * @throws \TYPO3\CMS\Extbase\Mvc\Exception\UnsupportedRequestTypeException |
||
| 328 | */ |
||
| 329 | public function updateDocumentAction(\EWW\Dpf\Domain\Model\DocumentForm $documentForm, $saveMode = null, $backToList = false) |
||
| 330 | { |
||
| 331 | try { |
||
| 332 | /** @var \EWW\Dpf\Domain\Model\Document $document */ |
||
| 333 | $document = $this->documentRepository->findByUid($documentForm->getDocumentUid()); |
||
| 334 | $depositLicense = $document->getDepositLicense(); |
||
| 335 | |||
| 336 | if ( |
||
| 337 | !$this->authorizationChecker->isGranted(DocumentVoter::UPDATE, $document) || |
||
| 338 | ( |
||
| 339 | $saveMode == 'saveWorkingCopy' && |
||
| 340 | $this->security->getUserRole() !== Security::ROLE_LIBRARIAN |
||
| 341 | ) |
||
| 342 | ) { |
||
| 343 | $message = LocalizationUtility::translate( |
||
| 344 | 'LLL:EXT:dpf/Resources/Private/Language/locallang.xlf:document_update.accessDenied', |
||
| 345 | 'dpf', |
||
| 346 | array($document->getTitle()) |
||
| 347 | ); |
||
| 348 | $this->addFlashMessage($message, '', AbstractMessage::ERROR); |
||
| 349 | |||
| 350 | $this->redirect('cancelEdit', |
||
| 351 | null, |
||
| 352 | null, |
||
| 353 | ['documentUid' => $document->getUid(), 'backToList' => $backToList] |
||
| 354 | ); |
||
| 355 | /* |
||
| 356 | $this->redirect( |
||
| 357 | 'showDetails', 'Document', |
||
| 358 | null, ['document' => $document] |
||
| 359 | ); |
||
| 360 | */ |
||
| 361 | |||
| 362 | } |
||
| 363 | |||
| 364 | /** @var \EWW\Dpf\Helper\DocumentMapper $documentMapper */ |
||
| 365 | $documentMapper = $this->objectManager->get(DocumentMapper::class); |
||
| 366 | |||
| 367 | /** @var \EWW\Dpf\Domain\Model\Document $updateDocument */ |
||
| 368 | $updateDocument = $documentMapper->getDocument($documentForm); |
||
| 369 | |||
| 370 | $saveWorkingCopy = false; |
||
| 371 | $workflowTransition = null; |
||
| 372 | |||
| 373 | // Convert the temporary copy into a local working copy if needed. |
||
| 374 | if ( $updateDocument->isTemporaryCopy() && $saveMode == 'saveWorkingCopy') { |
||
| 375 | $saveWorkingCopy = true; |
||
| 376 | $updateDocument->setTemporary(false); |
||
| 377 | $workflowTransition = DocumentWorkflow::TRANSITION_IN_PROGRESS; |
||
| 378 | } elseif ($updateDocument->isTemporaryCopy() && $saveMode == 'saveAndUpdate') { |
||
| 379 | $workflowTransition = DocumentWorkflow::TRANSITION_REMOTE_UPDATE; |
||
| 380 | } elseif ( |
||
| 381 | $this->security->getUserRole() === Security::ROLE_LIBRARIAN && |
||
| 382 | $updateDocument->getState() === DocumentWorkflow::STATE_REGISTERED_NONE |
||
| 383 | ) { |
||
| 384 | $workflowTransition = DocumentWorkflow::TRANSITION_IN_PROGRESS; |
||
| 385 | } |
||
| 386 | |||
| 387 | if ($this->documentManager->update($updateDocument, $workflowTransition)) { |
||
| 388 | |||
| 389 | $depositLicenseLog = $this->depositLicenseLogRepository->findOneByProcessNumber($document->getProcessNumber()); |
||
| 390 | if (empty($depositLicenseLog) && $updateDocument->getDepositLicense()) { |
||
| 391 | // Only if there was no deposit license a notification may be sent |
||
| 392 | |||
| 393 | /** @var DepositLicenseLog $depositLicenseLog */ |
||
| 394 | $depositLicenseLog = $this->objectManager->get(DepositLicenseLog::class); |
||
| 395 | $depositLicenseLog->setUsername($this->security->getUsername()); |
||
| 396 | $depositLicenseLog->setObjectIdentifier($document->getObjectIdentifier()); |
||
| 397 | $depositLicenseLog->setProcessNumber($document->getProcessNumber()); |
||
| 398 | $depositLicenseLog->setTitle($document->getTitle()); |
||
| 399 | $depositLicenseLog->setUrn($document->getPrimaryUrn()); |
||
| 400 | $depositLicenseLog->setLicenceUri($document->getDepositLicense()); |
||
| 401 | |||
| 402 | if ($document->hasFiles()) { |
||
| 403 | $fileList = []; |
||
| 404 | foreach ($document->getFile() as $file) { |
||
| 405 | $fileList[] = $file->getTitle(); |
||
| 406 | } |
||
| 407 | $depositLicenseLog->setFileNames(implode(", ", $fileList)); |
||
| 408 | } |
||
| 409 | |||
| 410 | |||
| 411 | $this->depositLicenseLogRepository->add($depositLicenseLog); |
||
| 412 | |||
| 413 | /** @var Notifier $notifier */ |
||
| 414 | $notifier = $this->objectManager->get(Notifier::class); |
||
| 415 | $notifier->sendDepositLicenseNotification($updateDocument); |
||
| 416 | } |
||
| 417 | |||
| 418 | $message = LocalizationUtility::translate( |
||
| 419 | 'LLL:EXT:dpf/Resources/Private/Language/locallang.xlf:document_update.success', |
||
| 420 | 'dpf', |
||
| 421 | array($updateDocument->getTitle()) |
||
| 422 | ); |
||
| 423 | $this->addFlashMessage($message, '', AbstractMessage::OK); |
||
| 424 | |||
| 425 | if ($this->security->getUserRole() === Security::ROLE_LIBRARIAN) { |
||
| 426 | if ($saveWorkingCopy) { |
||
| 427 | if ( |
||
| 428 | $this->bookmarkRepository->addBookmark( |
||
| 429 | $updateDocument, |
||
| 430 | $this->security->getUser()->getUid() |
||
| 431 | ) |
||
| 432 | ) { |
||
| 433 | $this->addFlashMessage( |
||
| 434 | LocalizationUtility::translate( |
||
| 435 | "manager.workspace.bookmarkAdded", "dpf" |
||
| 436 | ), |
||
| 437 | '', |
||
| 438 | AbstractMessage::INFO |
||
| 439 | ); |
||
| 440 | } |
||
| 441 | } else { |
||
| 442 | switch ($document->getState()) { |
||
| 443 | case DocumentWorkflow::STATE_POSTPONED_NONE: |
||
| 444 | case DocumentWorkflow::STATE_DISCARDED_NONE: |
||
| 445 | case DocumentWorkflow::STATE_NONE_INACTIVE: |
||
| 446 | case DocumentWorkflow::STATE_NONE_ACTIVE: |
||
| 447 | case DocumentWorkflow::STATE_NONE_DELETED: |
||
| 448 | |||
| 449 | if ( |
||
| 450 | $this->bookmarkRepository->removeBookmark( |
||
| 451 | $updateDocument, |
||
| 452 | $this->security->getUser()->getUid() |
||
| 453 | ) |
||
| 454 | ) { |
||
| 455 | $this->addFlashMessage( |
||
| 456 | LocalizationUtility::translate( |
||
| 457 | "manager.workspace.bookmarkRemoved.singular", "dpf" |
||
| 458 | ), |
||
| 459 | '', |
||
| 460 | AbstractMessage::INFO |
||
| 461 | ); |
||
| 462 | } |
||
| 463 | |||
| 464 | $this->redirectToDocumentList(); |
||
| 465 | |||
| 466 | break; |
||
| 467 | } |
||
| 468 | } |
||
| 469 | } |
||
| 470 | |||
| 471 | } else { |
||
| 472 | $message = LocalizationUtility::translate( |
||
| 473 | 'LLL:EXT:dpf/Resources/Private/Language/locallang.xlf:document_update.failure', |
||
| 474 | 'dpf', |
||
| 475 | array($updateDocument->getTitle()) |
||
| 476 | ); |
||
| 477 | $this->addFlashMessage($message, '', AbstractMessage::ERROR); |
||
| 478 | } |
||
| 479 | |||
| 480 | if ($workflowTransition && $workflowTransition === DocumentWorkflow::TRANSITION_REMOTE_UPDATE) { |
||
| 481 | $this->redirectToDocumentList(); |
||
| 482 | } else { |
||
| 483 | $this->redirect('cancelEdit', |
||
| 484 | null, |
||
| 485 | null, |
||
| 486 | ['documentUid' => $updateDocument->getUid(), 'backToList' => $backToList] |
||
| 487 | ); |
||
| 488 | // $this->redirect('showDetails', 'Document', null, ['document' => $updateDocument]); |
||
| 489 | } |
||
| 490 | } catch (\TYPO3\CMS\Extbase\Mvc\Exception\StopActionException $e) { |
||
| 491 | // A redirect always throws this exception, but in this case, however, |
||
| 492 | // redirection is desired and should not lead to an exception handling |
||
| 493 | } catch (\Exception $exception) { |
||
| 494 | $severity = AbstractMessage::ERROR; |
||
| 495 | |||
| 496 | if ($exception instanceof DPFExceptionInterface) { |
||
| 497 | $key = $exception->messageLanguageKey(); |
||
| 498 | } else { |
||
| 499 | $key = 'LLL:EXT:dpf/Resources/Private/Language/locallang.xlf:error.unexpected'; |
||
| 500 | } |
||
| 501 | |||
| 502 | $exceptionMsg[] = LocalizationUtility::translate( |
||
| 503 | 'LLL:EXT:dpf/Resources/Private/Language/locallang.xlf:document_update.failure', |
||
| 504 | 'dpf', |
||
| 505 | array($updateDocument->getTitle()) |
||
| 506 | ); |
||
| 507 | |||
| 508 | $exceptionMsg[] = LocalizationUtility::translate($key, 'dpf'); |
||
| 509 | |||
| 510 | $this->addFlashMessage(implode(" ", $exceptionMsg), '', $severity, true); |
||
| 511 | $this->redirect('cancelEdit', |
||
| 512 | null, |
||
| 513 | null, |
||
| 514 | ['documentUid' => $updateDocument->getUid(), 'backToList' => $backToList] |
||
| 515 | ); |
||
| 516 | $this->redirect('showDetails', 'Document', null, ['document' => $updateDocument]); |
||
| 517 | } |
||
| 518 | } |
||
| 519 | |||
| 520 | public function createAction(\EWW\Dpf\Domain\Model\DocumentForm $newDocumentForm) |
||
| 521 | { |
||
| 522 | /** @var \EWW\Dpf\Helper\DocumentMapper $documentMapper */ |
||
| 523 | $documentMapper = $this->objectManager->get(DocumentMapper::class); |
||
| 524 | |||
| 525 | /** @var \EWW\Dpf\Domain\Model\Document $document */ |
||
| 526 | $document = $documentMapper->getDocument($newDocumentForm); |
||
| 527 | |||
| 528 | if (!$this->authorizationChecker->isGranted(DocumentVoter::CREATE, $document)) { |
||
| 529 | $key = 'LLL:EXT:dpf/Resources/Private/Language/locallang.xlf:documentForm.create.accessDenied'; |
||
| 530 | $args[] = $document->getTitle(); |
||
| 531 | $message = LocalizationUtility::translate($key, 'dpf', $args); |
||
| 532 | $this->addFlashMessage($message, '', AbstractMessage::ERROR); |
||
| 533 | $this->redirect('showDetails', 'Document', null, ['document' => $document]); |
||
| 534 | return FALSE; |
||
| 535 | } |
||
| 536 | |||
| 537 | try { |
||
| 538 | parent::createAction($newDocumentForm); |
||
| 539 | |||
| 540 | $severity = AbstractMessage::OK; |
||
| 541 | $key = 'LLL:EXT:dpf/Resources/Private/Language/locallang.xlf:documentForm.create.ok'; |
||
| 542 | $message = LocalizationUtility::translate($key, 'dpf'); |
||
| 543 | $this->addFlashMessage( |
||
| 544 | $message, |
||
| 545 | '', |
||
| 546 | $severity, |
||
| 547 | true |
||
| 548 | ); |
||
| 549 | |||
| 550 | } catch (\TYPO3\CMS\Extbase\Mvc\Exception\StopActionException $e) { |
||
| 551 | // A redirect always throws this exception, but in this case, however, |
||
| 552 | // redirection is desired and should not lead to an exception handling |
||
| 553 | } catch (\Exception $exception) { |
||
| 554 | |||
| 555 | $severity = AbstractMessage::ERROR; |
||
| 556 | |||
| 557 | if ($exception instanceof DPFExceptionInterface) { |
||
| 558 | $key = $exception->messageLanguageKey(); |
||
| 559 | } else { |
||
| 560 | $key = 'LLL:EXT:dpf/Resources/Private/Language/locallang.xlf:error.unexpected'; |
||
| 561 | } |
||
| 562 | |||
| 563 | $message[] = LocalizationUtility::translate($key, 'dpf'); |
||
| 564 | |||
| 565 | $this->addFlashMessage( |
||
| 566 | implode(" ", $message), |
||
| 567 | '', |
||
| 568 | $severity, |
||
| 569 | true |
||
| 570 | ); |
||
| 571 | } |
||
| 572 | |||
| 573 | $this->redirect('listWorkspace', 'Workspace'); |
||
| 574 | } |
||
| 575 | |||
| 576 | |||
| 577 | /** |
||
| 578 | * action cancel edit |
||
| 579 | * |
||
| 580 | * @param integer $documentUid |
||
| 581 | * @param bool $backToList |
||
| 582 | * @throws \TYPO3\CMS\Extbase\Mvc\Exception\StopActionException |
||
| 583 | * @throws \TYPO3\CMS\Extbase\Mvc\Exception\UnsupportedRequestTypeException |
||
| 584 | * |
||
| 585 | * @return void |
||
| 586 | */ |
||
| 587 | public function cancelEditAction($documentUid = 0, $backToList = false) |
||
| 588 | { |
||
| 589 | if (empty($documentUid) || $backToList) { |
||
| 590 | $this->redirectToDocumentList(); |
||
| 591 | } |
||
| 592 | |||
| 593 | /** @var $document \EWW\Dpf\Domain\Model\Document */ |
||
| 594 | $document = $this->documentRepository->findByUid($documentUid); |
||
| 595 | $this->redirect('showDetails', 'Document', null, ['document' => $document]); |
||
| 596 | } |
||
| 597 | |||
| 598 | /** |
||
| 599 | * action cancel new |
||
| 600 | * |
||
| 601 | * @throws \TYPO3\CMS\Extbase\Mvc\Exception\StopActionException |
||
| 602 | * @throws \TYPO3\CMS\Extbase\Mvc\Exception\UnsupportedRequestTypeException |
||
| 603 | * |
||
| 604 | * @return void |
||
| 605 | */ |
||
| 606 | public function cancelNewAction() |
||
| 609 | } |
||
| 610 | |||
| 611 | |||
| 612 | public function initializeAction() |
||
| 613 | { |
||
| 614 | $this->authorizationChecker->denyAccessUnlessLoggedIn(); |
||
| 615 | |||
| 616 | parent::initializeAction(); |
||
| 617 | |||
| 618 | } |
||
| 619 | |||
| 620 | /** |
||
| 621 | * Redirect to the current document list. |
||
| 622 | * |
||
| 623 | * @param null $message |
||
| 624 | * @throws \TYPO3\CMS\Extbase\Mvc\Exception\StopActionException |
||
| 625 | * @throws \TYPO3\CMS\Extbase\Mvc\Exception\UnsupportedRequestTypeException |
||
| 626 | */ |
||
| 627 | protected function redirectToDocumentList($message = null) |
||
| 635 | } |
||
| 636 | } |
||
| 637 | } |
||
| 638 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths