|
|
@@ -1,16 +1,21 @@
|
|
|
<?php
|
|
|
+declare(strict_types=1);
|
|
|
|
|
|
namespace Opentalent\OtAdmin\Http;
|
|
|
|
|
|
|
|
|
-use Opentalent\OtAdmin\Controller\ScanController;
|
|
|
+use Doctrine\DBAL\Driver\Exception;
|
|
|
use Opentalent\OtAdmin\Controller\SiteController;
|
|
|
+use Opentalent\OtCore\Exception\InvalidWebsiteConfigurationException;
|
|
|
+use Opentalent\OtCore\Exception\NoSuchOrganizationException;
|
|
|
+use Opentalent\OtCore\Exception\NoSuchRecordException;
|
|
|
+use Opentalent\OtCore\Exception\NoSuchWebsiteException;
|
|
|
use Psr\Log\LoggerAwareInterface;
|
|
|
use Psr\Log\LoggerAwareTrait;
|
|
|
-use TYPO3\CMS\Core\Database\ConnectionPool;
|
|
|
use TYPO3\CMS\Core\Http\JsonResponse;
|
|
|
use TYPO3\CMS\Core\Http\ServerRequest;
|
|
|
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
|
|
+use TYPO3\CMS\Extbase\Object\ObjectManager;
|
|
|
|
|
|
/**
|
|
|
* Actions for Http API calls
|
|
|
@@ -30,9 +35,13 @@ class ApiController implements LoggerAwareInterface
|
|
|
'/^172\.20\.\d{1,3}\.\d{1,3}$/', // 172.20.[0-255].[0-255] - Docker
|
|
|
];
|
|
|
|
|
|
- public function __construct(
|
|
|
- private readonly SiteController $siteController
|
|
|
- ) {}
|
|
|
+ private readonly SiteController $siteController;
|
|
|
+
|
|
|
+ public function __construct() {
|
|
|
+ // TODO: trouver une solution pour faire fonctionner l'injection de dépendances
|
|
|
+ $objectManager = GeneralUtility::makeInstance(ObjectManager::class);
|
|
|
+ $this->siteController = $objectManager->get(SiteController::class);
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
* Returns true if the client Ip is allowed
|
|
|
@@ -87,20 +96,23 @@ class ApiController implements LoggerAwareInterface
|
|
|
/**
|
|
|
* -- Target of the route 'site_infos' --
|
|
|
*
|
|
|
- * Return the main informations about the organization's website
|
|
|
+ * Return the main information about the organization's website
|
|
|
*
|
|
|
* @param ServerRequest $request
|
|
|
* @return JsonResponse
|
|
|
* @throws \Exception
|
|
|
*/
|
|
|
- public function getSiteInfosAction(ServerRequest $request): JsonResponse
|
|
|
+ public function getSiteInfosAction(
|
|
|
+ ServerRequest $request,
|
|
|
+ SiteController $siteController
|
|
|
+ ): JsonResponse
|
|
|
{
|
|
|
$this->assertIpAllowed();
|
|
|
|
|
|
$organizationId = $this->getOrganizationId($request);
|
|
|
|
|
|
|
|
|
- $infos = $this->siteController->getSiteInfosAction($organizationId);
|
|
|
+ $infos = $siteController->getSiteInfosAction($organizationId);
|
|
|
|
|
|
return new JsonResponse($infos);
|
|
|
}
|
|
|
@@ -366,10 +378,17 @@ class ApiController implements LoggerAwareInterface
|
|
|
* Returns the current status of the website
|
|
|
*
|
|
|
* @param ServerRequest $request
|
|
|
+ * @param SiteController $siteController
|
|
|
* @return JsonResponse
|
|
|
- * @throws \Exception
|
|
|
+ * @throws Exception
|
|
|
+ * @throws InvalidWebsiteConfigurationException
|
|
|
+ * @throws NoSuchOrganizationException
|
|
|
+ * @throws NoSuchRecordException
|
|
|
+ * @throws NoSuchWebsiteException
|
|
|
*/
|
|
|
- public function getSiteStatusAction(ServerRequest $request): JsonResponse
|
|
|
+ public function getSiteStatusAction(
|
|
|
+ ServerRequest $request
|
|
|
+ ): JsonResponse
|
|
|
{
|
|
|
$this->assertIpAllowed();
|
|
|
|
|
|
@@ -377,6 +396,7 @@ class ApiController implements LoggerAwareInterface
|
|
|
|
|
|
$queryParams = $request->getQueryParams();
|
|
|
$full = (isset($queryParams['full']) && $queryParams['full']);
|
|
|
+
|
|
|
$status = $this->siteController->getSiteStatusAction($organizationId, $full);
|
|
|
|
|
|
return new JsonResponse($status->toArray());
|