Commit ad6ef561 authored by Ryan McVeigh's avatar Ryan McVeigh
Browse files

Issue #3262552 by rymcveigh: Ensure code is D9/D10 ready

parent ccfe84c4
Loading
Loading
Loading
Loading

composer.json

deleted100644 → 0
+0 −27
Original line number Diff line number Diff line
{
  "name": "drupal/restfullogger",
  "description": "Provides a REST API endpoint for client-side logging to core's dblog.",
  "type": "drupal-module",
  "license": "GPL-2.0-or-later",
  "minimum-stability": "dev",
  "homepage": "https://drupal.org/project/restfullogger",
  "authors": [
    {
      "name": "Ryan McVeigh (rymcveigh)",
      "homepage": "https://www.drupal.org/u/rymcveigh",
      "role": "Maintainer"
    },
    {
      "name": "Contributors",
      "homepage": "https://www.drupal.org/node/3100720/committers",
      "role": "Contributor"
    }
  ],
  "support": {
    "issues": "https://www.drupal.org/project/issues/restfullogger?version=8.x",
    "source": "https://git.drupalcode.org/project/restfullogger"
  },
  "require": {
    "drupal/core": "^8.8 || ^9.0"
  }
}
+1 −2
Original line number Diff line number Diff line
name: 'RESTful Logger'
type: module
description: 'This module provides a REST resource for logging messages.'
core: 8.x
core_version_requirement: ^8 || ^9
core_version_requirement: ">=8"
package: 'Web services'
dependencies:
  - drupal:dblog
+1 −2
Original line number Diff line number Diff line
@@ -14,8 +14,7 @@ function restfullogger_help($route_name, RouteMatchInterface $route_match) {
  switch ($route_name) {
    // Main module help for the restfullogger module.
    case 'help.page.restfullogger':
      $output = '';
      $output .= '<h3>' . t('About') . '</h3>';
      $output = '<h3>' . t('About') . '</h3>';
      $output .= '<p>' . t('Provides a REST resource for logging messages.') . '</p>';
      return $output;

+7 −7
Original line number Diff line number Diff line
@@ -77,7 +77,7 @@ class RestfulLogger extends ResourceBase {
   * @return \Drupal\rest\ModifiedResourceResponse
   *   The HTTP response object.
   */
  public function post($data) {
  public function post($data): ModifiedResourceResponse {
    // Use current user after pass authentication to validate access.
    if (!$this->currentUser->hasPermission('post log messages')) {
      throw new AccessDeniedHttpException();
@@ -87,7 +87,7 @@ class RestfulLogger extends ResourceBase {
    $channel = empty($data['channel']) ? 'restfullogger' : $data['channel'];
    $severity = $this->validateAndParseSeverity($data);
    $path = $this->validateAndParsePath($data);
    $message = t('@message, path:  @path', [
    $message = $this->t('@message, path:  @path', [
      '@message' => $message,
      '@path' => $path,
    ]);
@@ -118,10 +118,10 @@ class RestfulLogger extends ResourceBase {
   * @throws \Symfony\Component\HttpKernel\Exception\BadRequestHttpException
   *   Thrown when the request is mal-formatted.
   */
  private function validateAndParseMessage(array $request) {
  private function validateAndParseMessage(array $request): string {
    // Check if the message value exists.
    if (empty($request['message'])) {
      throw new BadRequestHttpException(t('The message value is missing'));
      throw new BadRequestHttpException('The message value is missing');
    }
    return $request['message'];
  }
@@ -135,7 +135,7 @@ class RestfulLogger extends ResourceBase {
   * @return string
   *   The value for the severity.
   */
  private function validateAndParseSeverity(array $request) {
  private function validateAndParseSeverity(array $request): string {
    $levels = RfcLogLevel::getLevels();
    $severity = empty($request['severity']) ? LogLevel::NOTICE : Html::escape(strtolower($request['severity']));
    // Default 'Notice' if the level provided is not available.
@@ -154,10 +154,10 @@ class RestfulLogger extends ResourceBase {
   * @throws \Symfony\Component\HttpKernel\Exception\BadRequestHttpException
   *   Thrown when the request is mal-formatted.
   */
  private function validateAndParsePath(array $request) {
  private function validateAndParsePath(array $request): string {
    // Check if the path value exists.
    if (empty($request['path'])) {
      throw new BadRequestHttpException(t('The path value is missing'));
      throw new BadRequestHttpException('The path value is missing');
    }
    return $request['path'];
  }
+1 −1
Original line number Diff line number Diff line
@@ -47,7 +47,7 @@ class LoadTest extends BrowserTestBase {
    $body = $this->container->get('serializer')->serialize([
      'message' => 'Test message',
      'path' => '/',
      'severity' => 'notice'
      'severity' => 'notice',
    ], 'json');
    $request_options = [
      'cookies' => $this->getSessionCookies(),