| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- <?php
- namespace Opentalent\OtAdmin\Controller;
- use Opentalent\OtCore\Controller\ActionController;
- use Opentalent\OtCore\Domain\Repository\OrganizationRepository;
- use TYPO3\CMS\Core\Utility\GeneralUtility;
- use TYPO3\CMS\Extbase\Object\ObjectManager;
- /**
- * The ScanController allows to scan the Typo3 DB to find potential issues
- */
- class ScanController extends ActionController
- {
- /**
- * Perform a full scan of the Typo3 DB, and confront it to the
- * Opentalent organizations list.
- *
- * Result is an array of the form:
- *
- * [
- * 'date' => Datetime,
- * 'stats' => [
- * status => count,
- * ...
- * ]
- * 'results' => [
- * organization_id => status,
- * ...
- * ]
- * ]
- *
- *
- * @param bool $fullScan If true, a 'warnings' entry will be added to the result of each site status,
- * and a full scan of the website pages will be performed.
- * @return array
- */
- public function scanAllAction(bool $fullScan = false): array
- {
- $organizationRepository = GeneralUtility::makeInstance(ObjectManager::class)->get(OrganizationRepository::class);
- $siteController = GeneralUtility::makeInstance(ObjectManager::class)->get(SiteController::class);
- $results = [];
- $stats = [];
- $organizationsCollection = $organizationRepository->getAll();
- foreach ($organizationsCollection->getMembers() as $organization) {
- $status = $siteController->getSiteStatusAction($organization->getId(), $fullScan);
- $results[$organization->getId()] = $status;
- if (!isset($stats[$status['status']])) {
- $stats[$status['status']] = 0;
- }
- $stats[$status['status']] += 1;
- }
- return [
- 'date' => new \DateTime(),
- 'stats' => $stats,
- 'results' => $results
- ];
- }
- }
|