diff --git a/site_audit_server.info.yml b/site_audit_server.info.yml index 2dfbe46..67a0321 100644 --- a/site_audit_server.info.yml +++ b/site_audit_server.info.yml @@ -4,7 +4,7 @@ description: Provides an API endpoint to receive site audit reports. package: Site Audit core_version_requirement: ^9 || ^10 dependencies: - - site_audit - - key_auth - - rest - - restui + - drupal:site_audit + - drupal:key_auth + - drupal:rest + - drupal:restui diff --git a/src/Form/SettingsForm.php b/src/Form/SettingsForm.php index 092418e..9f41a68 100644 --- a/src/Form/SettingsForm.php +++ b/src/Form/SettingsForm.php @@ -36,16 +36,6 @@ class SettingsForm extends ConfigFormBase { return parent::buildForm($form, $form_state); } - /** - * {@inheritdoc} - */ - public function validateForm(array &$form, FormStateInterface $form_state) { -// if ($form_state->getValue('allowed_clients') != 'allowed_clients') { -// $form_state->setErrorByName('example', $this->t('The value is not correct.')); -// } - parent::validateForm($form, $form_state); - } - /** * {@inheritdoc} */ diff --git a/src/Plugin/rest/resource/SiteAuditRemoteApiResource.php b/src/Plugin/rest/resource/SiteAuditRemoteApiResource.php index 161c9a6..527d5c5 100644 --- a/src/Plugin/rest/resource/SiteAuditRemoteApiResource.php +++ b/src/Plugin/rest/resource/SiteAuditRemoteApiResource.php @@ -2,14 +2,10 @@ namespace Drupal\site_audit_server\Plugin\rest\resource; -use Drupal\Core\KeyValueStore\KeyValueFactoryInterface; -use Drupal\custom_events\Event\SiteAuditReceiveEvent; use Drupal\rest\ModifiedResourceResponse; use Drupal\rest\Plugin\ResourceBase; -use Drupal\rest\ResourceResponse; use Psr\Log\LoggerInterface; use Symfony\Component\DependencyInjection\ContainerInterface; -use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; /** @@ -58,7 +54,7 @@ class SiteAuditRemoteApiResource extends ResourceBase { array $serializer_formats, LoggerInterface $logger ) { - parent::__construct($configuration, $plugin_id, $plugin_definition, $serializer_formats, $logger, ); + $this->logger = $logger; } /** @@ -88,7 +84,7 @@ class SiteAuditRemoteApiResource extends ResourceBase { if (isset($data['test']) && $data['test']) { $headers['Message'] = $this->t('Test POST was successful.'); - $this->logger->notice($this->t('Remote Test Received from IP :ip',[ + $this->logger->notice($this->t('Remote Test Received from IP :ip', [ ':ip' => $request->getClientIp(), ])); return new ModifiedResourceResponse($data, 200, $headers); @@ -96,15 +92,15 @@ class SiteAuditRemoteApiResource extends ResourceBase { elseif (isset($data['report']) && $data['report']) { $entity_data = $data['report']; - // currentUser should be the REST API Authenticated user (Usually API key.)) + // currentUser should be the REST API Authenticated user + // (Usually API key.)) $entity_data['uid'] = \Drupal::currentUser()->id(); - $report_entity = \Drupal::entityTypeManager() + $report_entity = \Drupal::entityTypeManager() ->getStorage('site_audit_report') - ->create($entity_data) - ; + ->create($entity_data); $report_entity->save(); - $url = $report_entity->toUrl('canonical', [ + $url = $report_entity->toUrl('canonical', [ 'absolute' => TRUE, ])->toString(); $this->logger->notice($this->t('Remote Report Received from :ip: :label - :url', [ @@ -113,7 +109,7 @@ class SiteAuditRemoteApiResource extends ResourceBase { ':ip' => $request->getClientIp(), ])); - # @TODO: Allow modules to add to responses. + // @todo Allow modules to add to responses. $headers = [ 'Message' => $this->t('Report Received.'), 'ReportUri' => $url, @@ -140,12 +136,10 @@ class SiteAuditRemoteApiResource extends ResourceBase { * * @param int $id * The ID of the record. - * - * @return \Drupal\rest\ResourceResponse - * The response containing the record. */ public function get($id) { - # @TODO: Mimic entity get + // @todo Mimic entity get throw new NotFoundHttpException(); } + }