| Total Complexity | 72 |
| Total Lines | 686 |
| Duplicated Lines | 0 % |
| Changes | 4 | ||
| Bugs | 0 | Features | 0 |
Complex classes like WorkspaceController 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 WorkspaceController, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 30 | class WorkspaceController extends AbstractController |
||
| 31 | { |
||
| 32 | /** |
||
| 33 | * FrontendUserRepository |
||
| 34 | * |
||
| 35 | * @var TYPO3\CMS\Extbase\Domain\Repository\FrontendUserRepository |
||
|
|
|||
| 36 | * @inject |
||
| 37 | */ |
||
| 38 | protected $frontendUserRepository; |
||
| 39 | |||
| 40 | /** |
||
| 41 | * documentRepository |
||
| 42 | * |
||
| 43 | * @var \EWW\Dpf\Domain\Repository\DocumentRepository |
||
| 44 | * @inject |
||
| 45 | */ |
||
| 46 | protected $documentRepository = null; |
||
| 47 | |||
| 48 | /** |
||
| 49 | * documentTypeRepository |
||
| 50 | * |
||
| 51 | * @var \EWW\Dpf\Domain\Repository\DocumentTypeRepository |
||
| 52 | * @inject |
||
| 53 | */ |
||
| 54 | protected $documentTypeRepository = null; |
||
| 55 | |||
| 56 | /** |
||
| 57 | * bookmarkRepository |
||
| 58 | * |
||
| 59 | * @var \EWW\Dpf\Domain\Repository\BookmarkRepository |
||
| 60 | * @inject |
||
| 61 | */ |
||
| 62 | protected $bookmarkRepository = null; |
||
| 63 | |||
| 64 | /** |
||
| 65 | * elasticSearch |
||
| 66 | * |
||
| 67 | * @var \EWW\Dpf\Services\ElasticSearch\ElasticSearch |
||
| 68 | * @inject |
||
| 69 | */ |
||
| 70 | protected $elasticSearch = null; |
||
| 71 | |||
| 72 | |||
| 73 | /** |
||
| 74 | * queryBuilder |
||
| 75 | * |
||
| 76 | * @var \EWW\Dpf\Services\ElasticSearch\QueryBuilder |
||
| 77 | * @inject |
||
| 78 | */ |
||
| 79 | protected $queryBuilder = null; |
||
| 80 | |||
| 81 | /** |
||
| 82 | * documentManager |
||
| 83 | * |
||
| 84 | * @var \EWW\Dpf\Services\Document\DocumentManager |
||
| 85 | * @inject |
||
| 86 | */ |
||
| 87 | protected $documentManager = null; |
||
| 88 | |||
| 89 | /** |
||
| 90 | * documentValidator |
||
| 91 | * |
||
| 92 | * @var \EWW\Dpf\Helper\DocumentValidator |
||
| 93 | * @inject |
||
| 94 | */ |
||
| 95 | protected $documentValidator; |
||
| 96 | |||
| 97 | /** |
||
| 98 | * editingLockService |
||
| 99 | * |
||
| 100 | * @var \EWW\Dpf\Services\Document\EditingLockService |
||
| 101 | * @inject |
||
| 102 | */ |
||
| 103 | protected $editingLockService = null; |
||
| 104 | |||
| 105 | |||
| 106 | /** |
||
| 107 | * list |
||
| 108 | * |
||
| 109 | * @param int $from |
||
| 110 | * @return void |
||
| 111 | */ |
||
| 112 | protected function list($from = 0) |
||
| 113 | { |
||
| 114 | $bookmarkIdentifiers = []; |
||
| 115 | foreach ($this->bookmarkRepository->findByFeUserUid($this->security->getUser()->getUid()) as $bookmark) { |
||
| 116 | $bookmarkIdentifiers[] = $bookmark->getDocumentIdentifier(); |
||
| 117 | } |
||
| 118 | |||
| 119 | /** @var SearchSessionData $workspaceSessionData */ |
||
| 120 | $workspaceSessionData = $this->session->getWorkspaceData(); |
||
| 121 | $filters = $workspaceSessionData->getFilters(); |
||
| 122 | $excludeFilters = $workspaceSessionData->getExcludeFilters(); |
||
| 123 | $sortField = $workspaceSessionData->getSortField(); |
||
| 124 | $sortOrder = $workspaceSessionData->getSortOrder(); |
||
| 125 | |||
| 126 | if ($this->security->getUser()->getUserRole() == Security::ROLE_LIBRARIAN) { |
||
| 127 | $query = $this->getWorkspaceQuery($from, $bookmarkIdentifiers, |
||
| 128 | $filters, $excludeFilters, $sortField, $sortOrder); |
||
| 129 | } elseif ($this->security->getUser()->getUserRole() == Security::ROLE_RESEARCHER) { |
||
| 130 | $query = $this->getMyPublicationsQuery($from, $bookmarkIdentifiers, |
||
| 131 | $filters, $excludeFilters, $sortField, $sortOrder); |
||
| 132 | } |
||
| 133 | |||
| 134 | try { |
||
| 135 | $results = $this->elasticSearch->search($query, 'object'); |
||
| 136 | } catch (\Exception $e) { |
||
| 137 | $workspaceSessionData->clearSort(); |
||
| 138 | $workspaceSessionData->clearFilters(); |
||
| 139 | $this->session->setWorkspaceData($workspaceSessionData); |
||
| 140 | $this->addFlashMessage( |
||
| 141 | "Error while buildig the list!", '', AbstractMessage::ERROR |
||
| 142 | ); |
||
| 143 | } |
||
| 144 | |||
| 145 | if ($this->request->hasArgument('message')) { |
||
| 146 | $this->view->assign('message', $this->request->getArgument('message')); |
||
| 147 | } |
||
| 148 | |||
| 149 | if ($this->request->hasArgument('errorFiles')) { |
||
| 150 | $this->view->assign('errorFiles', $this->request->getArgument('errorFiles')); |
||
| 151 | } |
||
| 152 | |||
| 153 | if ($filters && $results['hits']['total']['value'] < 1) { |
||
| 154 | $this->session->clearFilter(); |
||
| 155 | list($redirectAction, $redirectController) = $this->session->getListAction(); |
||
| 156 | $this->redirect( |
||
| 157 | $redirectAction, $redirectController, null, |
||
| 158 | array('message' => [], 'checkedDocumentIdentifiers' => []) |
||
| 159 | ); |
||
| 160 | } |
||
| 161 | |||
| 162 | $this->view->assign('documentCount', $results['hits']['total']['value']); |
||
| 163 | $this->view->assign('documents', $results['hits']['hits']); |
||
| 164 | $this->view->assign('pages', range(1, $results['hits']['total']['value'])); |
||
| 165 | $this->view->assign('itemsPerPage', $this->itemsPerPage()); |
||
| 166 | $this->view->assign('aggregations', $results['aggregations']); |
||
| 167 | $this->view->assign('filters', $filters); |
||
| 168 | $this->view->assign('isHideDiscarded', array_key_exists('aliasState', $excludeFilters)); |
||
| 169 | $this->view->assign('isBookmarksOnly', array_key_exists('bookmarks', $excludeFilters)); |
||
| 170 | $this->view->assign('bookmarkIdentifiers', $bookmarkIdentifiers); |
||
| 171 | } |
||
| 172 | |||
| 173 | /** |
||
| 174 | * Lists documents of the workspace |
||
| 175 | * |
||
| 176 | * @param array $checkedDocumentIdentifiers |
||
| 177 | * |
||
| 178 | * @return void |
||
| 179 | */ |
||
| 180 | protected function listWorkspaceAction($checkedDocumentIdentifiers = []) |
||
| 181 | { |
||
| 182 | $args = $this->request->getArguments(); |
||
| 183 | if ($args['refresh']) { |
||
| 184 | $workspaceSessionData = $this->session->getWorkspaceData(); |
||
| 185 | $workspaceSessionData->clearSort(); |
||
| 186 | $workspaceSessionData->clearFilters(); |
||
| 187 | |||
| 188 | $this->session->setWorkspaceData($workspaceSessionData); |
||
| 189 | } |
||
| 190 | |||
| 191 | if ($this->security->getUser()->getUserRole() === Security::ROLE_LIBRARIAN) { |
||
| 192 | $this->view->assign('isWorkspace', true); |
||
| 193 | } elseif ($this->security->getUser()->getUserRole() === Security::ROLE_RESEARCHER) { |
||
| 194 | $this->view->assign('isWorkspace', false); |
||
| 195 | } else { |
||
| 196 | $message = LocalizationUtility::translate( |
||
| 197 | 'manager.workspace.accessDenied', 'dpf' |
||
| 198 | ); |
||
| 199 | $this->addFlashMessage($message, '', AbstractMessage::ERROR); |
||
| 200 | } |
||
| 201 | |||
| 202 | $this->session->setListAction($this->getCurrentAction(), $this->getCurrentController(), |
||
| 203 | $this->uriBuilder->getRequest()->getRequestUri() |
||
| 204 | ); |
||
| 205 | |||
| 206 | $currentPage = null; |
||
| 207 | $pagination = $this->getParametersSafely('@widget_0'); |
||
| 208 | if ($pagination) { |
||
| 209 | $checkedDocumentIdentifiers = []; |
||
| 210 | $currentPage = $pagination['currentPage']; |
||
| 211 | } else { |
||
| 212 | $currentPage = 1; |
||
| 213 | } |
||
| 214 | |||
| 215 | $this->list((empty($currentPage)? 0 : ($currentPage-1) * $this->itemsPerPage())); |
||
| 216 | |||
| 217 | $this->view->assign('currentPage', $currentPage); |
||
| 218 | $this->view->assign('workspaceListAction', $this->getCurrentAction()); |
||
| 219 | $this->view->assign('checkedDocumentIdentifiers', $checkedDocumentIdentifiers); |
||
| 220 | } |
||
| 221 | |||
| 222 | |||
| 223 | /** |
||
| 224 | * Batch operations action. |
||
| 225 | * @param array $listData |
||
| 226 | */ |
||
| 227 | public function batchAction($listData) |
||
| 231 | } |
||
| 232 | } |
||
| 233 | |||
| 234 | /** |
||
| 235 | * Batch operation, register documents. |
||
| 236 | * @param array $listData |
||
| 237 | * @throws \EWW\Dpf\Exceptions\DocumentMaxSizeErrorException |
||
| 238 | */ |
||
| 239 | public function batchRegisterAction($listData) |
||
| 240 | { |
||
| 241 | $successful = []; |
||
| 242 | $checkedDocumentIdentifiers = []; |
||
| 243 | |||
| 244 | if (array_key_exists('documentIdentifiers', $listData) && is_array($listData['documentIdentifiers']) ) { |
||
| 245 | $checkedDocumentIdentifiers = $listData['documentIdentifiers']; |
||
| 246 | foreach ($listData['documentIdentifiers'] as $documentIdentifier) { |
||
| 247 | |||
| 248 | $this->editingLockService->lock( |
||
| 249 | $documentIdentifier, $this->security->getUser()->getUid() |
||
| 250 | ); |
||
| 251 | |||
| 252 | if (is_numeric($documentIdentifier)) { |
||
| 253 | $document = $this->documentManager->read($documentIdentifier); |
||
| 254 | |||
| 255 | if ($this->authorizationChecker->isGranted(DocumentVoter::REGISTER, $document)) { |
||
| 256 | |||
| 257 | if ($this->documentValidator->validate($document)) { |
||
| 258 | |||
| 259 | if ( |
||
| 260 | $this->documentManager->update( |
||
| 261 | $document, |
||
| 262 | DocumentWorkflow::TRANSITION_REGISTER |
||
| 263 | ) |
||
| 264 | ) { |
||
| 265 | $this->bookmarkRepository->addBookmark( |
||
| 266 | $this->security->getUser()->getUid(), $document |
||
| 267 | ); |
||
| 268 | |||
| 269 | $successful[] = $documentIdentifier; |
||
| 270 | |||
| 271 | $notifier = $this->objectManager->get(Notifier::class); |
||
| 272 | $notifier->sendRegisterNotification($document); |
||
| 273 | |||
| 274 | // index the document |
||
| 275 | $this->signalSlotDispatcher->dispatch( |
||
| 276 | \EWW\Dpf\Controller\AbstractController::class, |
||
| 277 | 'indexDocument', [$document] |
||
| 278 | ); |
||
| 279 | } |
||
| 280 | } |
||
| 281 | } |
||
| 282 | } |
||
| 283 | } |
||
| 284 | |||
| 285 | |||
| 286 | if (sizeof($successful) == 1) { |
||
| 287 | $locallangKey = 'manager.workspace.batchAction.register.success.singular'; |
||
| 288 | } else { |
||
| 289 | $locallangKey = 'manager.workspace.batchAction.register.success.plural'; |
||
| 290 | } |
||
| 291 | |||
| 292 | $message = LocalizationUtility::translate( |
||
| 293 | $locallangKey, |
||
| 294 | 'dpf', |
||
| 295 | [sizeof($successful), sizeof($listData['documentIdentifiers'])] |
||
| 296 | ); |
||
| 297 | |||
| 298 | |||
| 299 | $this->addFlashMessage( |
||
| 300 | $message, '', |
||
| 301 | (sizeof($successful) > 0 ? AbstractMessage::OK : AbstractMessage::WARNING) |
||
| 302 | ); |
||
| 303 | |||
| 304 | } else { |
||
| 305 | $message = LocalizationUtility::translate( |
||
| 306 | 'manager.workspace.batchAction.failure', |
||
| 307 | 'dpf'); |
||
| 308 | $this->addFlashMessage($message, '', AbstractMessage::ERROR); |
||
| 309 | } |
||
| 310 | |||
| 311 | list($redirectAction, $redirectController) = $this->session->getListAction(); |
||
| 312 | $this->redirect( |
||
| 313 | $redirectAction, $redirectController, null, |
||
| 314 | array('message' => $message, 'checkedDocumentIdentifiers' => $checkedDocumentIdentifiers)); |
||
| 315 | } |
||
| 316 | |||
| 317 | /** |
||
| 318 | * Batch operation, remove documents. |
||
| 319 | * @param array $listData |
||
| 320 | */ |
||
| 321 | public function batchRemoveAction($listData) |
||
| 322 | { |
||
| 323 | $successful = []; |
||
| 324 | $checkedDocumentIdentifiers = []; |
||
| 325 | |||
| 326 | if (array_key_exists('documentIdentifiers', $listData) && is_array($listData['documentIdentifiers']) ) { |
||
| 327 | $checkedDocumentIdentifiers = $listData['documentIdentifiers']; |
||
| 328 | foreach ($listData['documentIdentifiers'] as $documentIdentifier) { |
||
| 329 | $feUserUid = $this->security->getUser()->getUid(); |
||
| 330 | $bookmark = $this->bookmarkRepository->findBookmark($feUserUid, $documentIdentifier); |
||
| 331 | if ($bookmark instanceof Bookmark) { |
||
| 332 | $this->bookmarkRepository->remove($bookmark); |
||
| 333 | $successful[] = $documentIdentifier; |
||
| 334 | } |
||
| 335 | } |
||
| 336 | |||
| 337 | |||
| 338 | if (sizeof($successful) == 1) { |
||
| 339 | $locallangKey = 'manager.workspace.batchAction.remove.success.singular'; |
||
| 340 | } else { |
||
| 341 | $locallangKey = 'manager.workspace.batchAction.remove.success.plural'; |
||
| 342 | } |
||
| 343 | |||
| 344 | $message = LocalizationUtility::translate( |
||
| 345 | $locallangKey, |
||
| 346 | 'dpf', |
||
| 347 | [sizeof($successful), sizeof($listData['documentIdentifiers'])] |
||
| 348 | ); |
||
| 349 | $this->addFlashMessage( |
||
| 350 | $message, '', |
||
| 351 | (sizeof($successful) > 0 ? AbstractMessage::OK : AbstractMessage::WARNING) |
||
| 352 | ); |
||
| 353 | } else { |
||
| 354 | $message = LocalizationUtility::translate( |
||
| 355 | 'manager.workspace.batchAction.failure', |
||
| 356 | 'dpf'); |
||
| 357 | $this->addFlashMessage($message, '', AbstractMessage::ERROR); |
||
| 358 | } |
||
| 359 | |||
| 360 | list($redirectAction, $redirectController) = $this->session->getListAction(); |
||
| 361 | $this->redirect( |
||
| 362 | $redirectAction, $redirectController, null, |
||
| 363 | array('message' => $message, 'checkedDocumentIdentifiers' => $checkedDocumentIdentifiers)); |
||
| 364 | } |
||
| 365 | |||
| 366 | |||
| 367 | /** |
||
| 368 | * Batch operation, release documents. |
||
| 369 | * @param array $listData |
||
| 370 | */ |
||
| 371 | public function batchReleaseValidatedAction($listData) |
||
| 372 | { |
||
| 373 | $this->batchRelease($listData, true); |
||
| 374 | } |
||
| 375 | |||
| 376 | /** |
||
| 377 | * Batch operation, release as unvalidated documents. |
||
| 378 | * @param array $listData |
||
| 379 | */ |
||
| 380 | public function batchReleaseUnvalidatedAction($listData) |
||
| 381 | { |
||
| 382 | $this->batchRelease($listData, false); |
||
| 383 | } |
||
| 384 | |||
| 385 | |||
| 386 | |||
| 387 | |||
| 388 | /** |
||
| 389 | * Batch operation, release documents. |
||
| 390 | * @param array $listData |
||
| 391 | * @param bool $validated |
||
| 392 | */ |
||
| 393 | protected function batchRelease($listData, $validated) |
||
| 394 | { |
||
| 395 | $successful = []; |
||
| 396 | $checkedDocumentIdentifiers = []; |
||
| 397 | |||
| 398 | if (array_key_exists('documentIdentifiers', $listData) && is_array($listData['documentIdentifiers']) ) { |
||
| 399 | $checkedDocumentIdentifiers = $listData['documentIdentifiers']; |
||
| 400 | foreach ($listData['documentIdentifiers'] as $documentIdentifier) { |
||
| 401 | |||
| 402 | $this->editingLockService->lock( |
||
| 403 | $documentIdentifier, $this->security->getUser()->getUid() |
||
| 404 | ); |
||
| 405 | |||
| 406 | $document = $this->documentManager->read($documentIdentifier); |
||
| 407 | |||
| 408 | switch ($document->getState()) { |
||
| 409 | case DocumentWorkflow::STATE_REGISTERED_NONE: |
||
| 410 | case DocumentWorkflow::STATE_DISCARDED_NONE: |
||
| 411 | case DocumentWorkflow::STATE_POSTPONED_NONE: |
||
| 412 | $documentVoterAttribute = DocumentVoter::RELEASE_PUBLISH; |
||
| 413 | $documentWorkflowTransition = DocumentWorkflow::TRANSITION_RELEASE_PUBLISH; |
||
| 414 | break; |
||
| 415 | |||
| 416 | case DocumentWorkflow::STATE_NONE_DELETED: |
||
| 417 | case DocumentWorkflow::STATE_NONE_INACTIVE: |
||
| 418 | case DocumentWorkflow::STATE_IN_PROGRESS_DELETED: |
||
| 419 | case DocumentWorkflow::STATE_IN_PROGRESS_INACTIVE: |
||
| 420 | case DocumentWorkflow::STATE_IN_PROGRESS_ACTIVE: |
||
| 421 | $documentVoterAttribute = DocumentVoter::RELEASE_ACTIVATE; |
||
| 422 | $documentWorkflowTransition = DocumentWorkflow::TRANSITION_RELEASE_ACTIVATE; |
||
| 423 | break; |
||
| 424 | default: |
||
| 425 | $documentVoterAttribute = null; |
||
| 426 | $documentWorkflowTransition = null; |
||
| 427 | break; |
||
| 428 | } |
||
| 429 | |||
| 430 | if ($this->authorizationChecker->isGranted($documentVoterAttribute, $document)) { |
||
| 431 | |||
| 432 | $slub = new \EWW\Dpf\Helper\Slub($document->getSlubInfoData()); |
||
| 433 | |||
| 434 | $slub->setValidation($validated); |
||
| 435 | $document->setSlubInfoData($slub->getSlubXml()); |
||
| 436 | |||
| 437 | if ($this->documentManager->update($document, $documentWorkflowTransition)) { |
||
| 438 | $successful[] = $documentIdentifier; |
||
| 439 | |||
| 440 | $this->bookmarkRepository->removeBookmark( |
||
| 441 | $document, $this->security->getUser()->getUid() |
||
| 442 | ); |
||
| 443 | |||
| 444 | //$notifier = $this->objectManager->get(Notifier::class); |
||
| 445 | //$notifier->sendRegisterNotification($document); |
||
| 446 | } |
||
| 447 | } |
||
| 448 | } |
||
| 449 | |||
| 450 | if (sizeof($successful) == 1) { |
||
| 451 | $locallangKey = 'manager.workspace.batchAction.release.success.singular'; |
||
| 452 | } else { |
||
| 453 | $locallangKey = 'manager.workspace.batchAction.release.success.plural'; |
||
| 454 | } |
||
| 455 | |||
| 456 | $message = LocalizationUtility::translate( |
||
| 457 | $locallangKey, |
||
| 458 | 'dpf', |
||
| 459 | [sizeof($successful), sizeof($listData['documentIdentifiers'])] |
||
| 460 | ); |
||
| 461 | $this->addFlashMessage( |
||
| 462 | $message, '', |
||
| 463 | (sizeof($successful) > 0 ? AbstractMessage::OK : AbstractMessage::WARNING) |
||
| 464 | ); |
||
| 465 | |||
| 466 | if (sizeof($successful) === 1 ) { |
||
| 467 | $this->addFlashMessage( |
||
| 468 | "1 ".LocalizationUtility::translate("manager.workspace.bookmarkRemoved.singular", "dpf"), |
||
| 469 | '', |
||
| 470 | AbstractMessage::INFO |
||
| 471 | ); |
||
| 472 | } |
||
| 473 | |||
| 474 | if (sizeof($successful) > 1 ) { |
||
| 475 | $this->addFlashMessage( |
||
| 476 | LocalizationUtility::translate( |
||
| 477 | "manager.workspace.bookmarkRemoved.plural", "dpf", [sizeof($successful)] |
||
| 478 | ), |
||
| 479 | '', |
||
| 480 | AbstractMessage::INFO |
||
| 481 | ); |
||
| 482 | } |
||
| 483 | |||
| 484 | } else { |
||
| 485 | $message = LocalizationUtility::translate( |
||
| 486 | 'manager.workspace.batchAction.failure', |
||
| 487 | 'dpf'); |
||
| 488 | $this->addFlashMessage($message, '', AbstractMessage::ERROR); |
||
| 489 | } |
||
| 490 | |||
| 491 | list($redirectAction, $redirectController) = $this->session->getListAction(); |
||
| 492 | $this->redirect( |
||
| 493 | $redirectAction, $redirectController, null, |
||
| 494 | array('message' => $message, 'checkedDocumentIdentifiers' => $checkedDocumentIdentifiers)); |
||
| 495 | |||
| 496 | } |
||
| 497 | |||
| 498 | /** |
||
| 499 | * get list view data for the workspace |
||
| 500 | * |
||
| 501 | * @param int $from |
||
| 502 | * @param array $bookmarkIdentifiers |
||
| 503 | * @param array $filters |
||
| 504 | * @param array $excludeFilters |
||
| 505 | * @param string $sortField |
||
| 506 | * @param string $sortOrder |
||
| 507 | * |
||
| 508 | * @return array |
||
| 509 | */ |
||
| 510 | protected function getWorkspaceQuery( |
||
| 511 | $from = 0, $bookmarkIdentifiers = [], $filters = [], $excludeFilters = [], $sortField = null, $sortOrder = null |
||
| 512 | ) |
||
| 513 | { |
||
| 514 | $workspaceFilter = [ |
||
| 515 | 'bool' => [ |
||
| 516 | 'must' => [ |
||
| 517 | [ |
||
| 518 | 'bool' => [ |
||
| 519 | 'must' => [ |
||
| 520 | [ |
||
| 521 | 'term' => [ |
||
| 522 | 'creator' => $this->security->getUser()->getUid() |
||
| 523 | ] |
||
| 524 | ], |
||
| 525 | [ |
||
| 526 | 'bool' => [ |
||
| 527 | 'should' => [ |
||
| 528 | [ |
||
| 529 | 'term' => [ |
||
| 530 | 'state' => DocumentWorkflow::STATE_NEW_NONE |
||
| 531 | ] |
||
| 532 | ] |
||
| 533 | ] |
||
| 534 | ] |
||
| 535 | ] |
||
| 536 | ] |
||
| 537 | ] |
||
| 538 | ] |
||
| 539 | ] |
||
| 540 | ] |
||
| 541 | ]; |
||
| 542 | |||
| 543 | return $this->queryBuilder->buildQuery( |
||
| 544 | $this->itemsPerPage(), $workspaceFilter, $from, $bookmarkIdentifiers, $filters, |
||
| 545 | $excludeFilters, $sortField, $sortOrder |
||
| 546 | ); |
||
| 547 | } |
||
| 548 | |||
| 549 | |||
| 550 | /** |
||
| 551 | * get list view data for the my publications list. |
||
| 552 | * |
||
| 553 | * @param int $from |
||
| 554 | * @param array $bookmarkIdentifiers |
||
| 555 | * @param array $filters |
||
| 556 | * @param array $excludeFilters |
||
| 557 | * @param string $sortField |
||
| 558 | * @param string $sortOrder |
||
| 559 | * |
||
| 560 | * @return array |
||
| 561 | */ |
||
| 562 | protected function getMyPublicationsQuery( |
||
| 581 | ); |
||
| 582 | } |
||
| 583 | |||
| 584 | |||
| 585 | /** |
||
| 586 | * A temporary solution to initialize the index. |
||
| 587 | * |
||
| 588 | * @param int $start |
||
| 589 | * @param int $stop |
||
| 590 | * @throws \TYPO3\CMS\Extbase\Persistence\Exception\IllegalObjectTypeException |
||
| 591 | */ |
||
| 592 | public function initIndexAction($start = 1, $stop = 100) |
||
| 593 | { |
||
| 594 | /** @var \TYPO3\CMS\Extbase\SignalSlot\Dispatcher $signalSlotDispatcher */ |
||
| 595 | $signalSlotDispatcher = $this->objectManager->get(\TYPO3\CMS\Extbase\SignalSlot\Dispatcher::class); |
||
| 596 | |||
| 597 | /** @var \EWW\Dpf\Services\Transfer\DocumentTransferManager $documentTransferManager */ |
||
| 598 | $documentTransferManager = $this->objectManager->get(\EWW\Dpf\Services\Transfer\DocumentTransferManager::class); |
||
| 599 | |||
| 600 | $fedoraRepository = $this->objectManager->get(\EWW\Dpf\Services\Transfer\FedoraRepository::class); |
||
| 601 | $documentTransferManager->setRemoteRepository($fedoraRepository); |
||
| 602 | |||
| 603 | for ($i = $start; $i < $stop; $i++) { |
||
| 604 | try { |
||
| 605 | $document = $documentTransferManager->retrieve('qucosa:' . $i); |
||
| 606 | |||
| 607 | if ($document instanceof Document) { |
||
| 608 | $state = $document->getState(); |
||
| 609 | $document->setState( |
||
| 610 | str_replace( |
||
| 611 | DocumentWorkflow::LOCAL_STATE_IN_PROGRESS, |
||
| 612 | DocumentWorkflow::LOCAL_STATE_NONE, |
||
| 613 | $state |
||
| 614 | ) |
||
| 615 | ); |
||
| 616 | |||
| 617 | // index the document |
||
| 618 | $signalSlotDispatcher->dispatch( |
||
| 619 | \EWW\Dpf\Controller\AbstractController::class, |
||
| 620 | 'indexDocument', [$document] |
||
| 621 | ); |
||
| 622 | |||
| 623 | $this->documentRepository->remove($document); |
||
| 624 | } |
||
| 625 | } catch (\EWW\Dpf\Exceptions\RetrieveDocumentErrorException $e) { |
||
| 626 | // Nothing to be done. |
||
| 627 | } |
||
| 628 | } |
||
| 629 | |||
| 630 | foreach ($this->documentRepository->findAll() as $document) { |
||
| 631 | if (!$document->isTemporary() && !$document->isSuggestion()) { |
||
| 632 | // index the document |
||
| 633 | $signalSlotDispatcher->dispatch( |
||
| 634 | \EWW\Dpf\Controller\AbstractController::class, |
||
| 635 | 'indexDocument', [$document] |
||
| 636 | ); |
||
| 637 | } |
||
| 638 | } |
||
| 639 | } |
||
| 640 | |||
| 641 | |||
| 642 | /** |
||
| 643 | * action uploadFiles |
||
| 644 | * |
||
| 645 | * @param string $documentIdentifier |
||
| 646 | * @return void |
||
| 647 | */ |
||
| 648 | public function uploadFilesAction($documentIdentifier) |
||
| 698 | } |
||
| 699 | |||
| 700 | } |
||
| 701 | |||
| 702 | |||
| 703 | /** |
||
| 704 | * Returns the number of items to be shown per page. |
||
| 705 | * |
||
| 706 | * @return int |
||
| 707 | */ |
||
| 708 | protected function itemsPerPage() |
||
| 716 | } |
||
| 717 | |||
| 718 | } |
||
| 719 |