ScanController.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. namespace Opentalent\OtAdmin\Controller;
  3. use Opentalent\OtAdmin\Domain\Entity\ScanReport;
  4. use Opentalent\OtCore\Controller\ActionController;
  5. use Opentalent\OtCore\Domain\Repository\OrganizationRepository;
  6. use TYPO3\CMS\Core\Utility\GeneralUtility;
  7. use TYPO3\CMS\Extbase\Object\ObjectManager;
  8. /**
  9. * ScanController scan the Typo3 DB to find potential issues
  10. */
  11. class ScanController extends ActionController
  12. {
  13. /**
  14. * Perform a full scan of the Typo3 DB, and confront it to the
  15. * Opentalent organizations list.
  16. *
  17. * @param bool $fullScan If true, a 'warnings' entry will be added to the result of each site status,
  18. * and a full scan of the website pages will be performed.
  19. * @return ScanReport
  20. */
  21. public function scanAllAction(bool $fullScan = false): ScanReport
  22. {
  23. $organizationRepository = GeneralUtility::makeInstance(ObjectManager::class)->get(OrganizationRepository::class);
  24. $siteController = GeneralUtility::makeInstance(ObjectManager::class)->get(SiteController::class);
  25. $report = new ScanReport();
  26. $organizationsCollection = $organizationRepository->getAll();
  27. foreach ($organizationsCollection->getMembers() as $organization) {
  28. $status = $siteController->getSiteStatusAction($organization->getId(), $fullScan);
  29. $report->setResultFor($organization->getId(), $status);
  30. }
  31. return $report;
  32. }
  33. }