Unverified Commit aad67508 authored by Mateu Aguiló Bosch's avatar Mateu Aguiló Bosch Committed by Mateu Aguiló Bosch
Browse files

Issue #3310649 by e0ipso: Audit page no longer reporting implemented hooks

parent b437cbbf
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -274,7 +274,7 @@ class Component {
        '%status' => $status,
        '%description' => $metadata->getDescription(),
      ];
      $title = $this->t("[DEBUG]\n\nComponent: \"%name\" (%id).\nVariant: %variant\nStatus: %status\nDescription: %description", $args);
      $title = $this->t("Component: \"%name\" (%id).\nVariant: %variant\nStatus: %status\nDescription: %description", $args);
      $attributes['title'] = $attributes['title'] ?? $title;
    }
    return [
+20 −13
Original line number Diff line number Diff line
@@ -5,7 +5,9 @@ namespace Drupal\cl_components\Controller;
use Drupal\cl_components\Component\Component;
use Drupal\cl_components\Component\ComponentDiscovery;
use Drupal\cl_components\Component\ComponentMetadata;
use Drupal\cl_components\Exception\ComponentSyntaxException;
use Drupal\cl_components\Exception\InvalidComponentException;
use Drupal\cl_components\Parser\ComponentPhpFile;
use Drupal\Component\Serialization\Json;
use Drupal\Component\Utility\Tags;
use Drupal\Core\Controller\ControllerBase;
@@ -187,17 +189,22 @@ final class ComponentAudit extends ControllerBase {
      ),
    ];
    if (!$is_forked) {
      $hooks_message = empty($hooks)
        ? [
          '#type' => 'html_tag',
          '#tag' => 'em',
          '#value' => $this->t('No hooks in <code>@filename</code>.', ['@filename' => $component->getId() . '.php']),
        ]
        : [
      try {
        $hooks = $component->getMetadata()->getHooks();
      }
      catch (ComponentSyntaxException $e) {
        $hooks = [];
      }
      $hooks_message = [
        '#theme' => 'item_list',
        '#items' => array_map(
            static fn(string $hook) => ['#type' => 'html_tag', '#tag' => 'code', '#value' => $hook],
            $hooks
          static fn(string $hook) => [
            '#type' => 'html_tag',
            '#tag' => 'code',
            '#value' => $hook,
            '#attributes' => ['class' => in_array($hook, $hooks, TRUE) ? 'implemented' : 'not-implemented'],
          ],
          ComponentPhpFile::SUPPORTED_CL_HOOKS
        ),
      ];
    }
+1 −1
Original line number Diff line number Diff line
@@ -9,7 +9,7 @@ use Drupal\Core\File\FileSystemInterface;

class ComponentPhpFile {

  private const SUPPORTED_CL_HOOKS = ['form_alter', 'library_info_alter'];
  public const SUPPORTED_CL_HOOKS = ['form_alter', 'library_info_alter'];

  /**
   * The path to the PHP file.
+6 −0
Original line number Diff line number Diff line
@@ -31,3 +31,9 @@ h4:hover a.panel-item--anchor {
  margin: 0;
  padding: 0;
}
.item-list ul .implemented::before {
  content: '✅ ';
}
.item-list ul .not-implemented {
  text-decoration: line-through;
}