<?php
/**
 * @file
 * Contains hooks and theme registrations for the PDF Forge module.
 *
 * PDF Forge generates PDF documents from Drupal render arrays using
 * the Dompdf library (pure PHP, no external binaries).
 *
 * Features:
 * - Provides a configurable service for rendering PDFs.
 * - Includes a settings UI for default font, page size, orientation,
 *   and remote asset permissions.
 * - Ships with a demo hub offering basic and advanced PDF examples.
 *
 * @ingroup pdf_forge
 */

use Drupal\Core\Routing\RouteMatchInterface;

/**
 * Implements hook_theme().
 *
 * Declares the `pdf_forge_print` theme hook, which is used to render
 * PDF output with optional CSS, header, and footer HTML.
 *
 * @param array $existing
 *   An array of existing implementations keyed by theme hook name.
 * @param string $type
 *   The type of hook being implemented; one of 'module', 'base_theme', or
 *   'theme_engine'.
 * @param string $theme
 *   The name of the theme implementing the hook.
 * @param string $path
 *   The path to the theme or module implementing the hook.
 *
 * @return array
 *   An associative array of theme hook definitions.
 */
function pdf_forge_theme(array $existing, $type, $theme, $path) {
  return [
    'pdf_forge_print' => [
      'variables' => [
        'title' => NULL,
        'css' => '',
        'content' => NULL,
        'header_html' => NULL,
        'footer_html' => NULL,
      ],
      'template' => 'pdf-forge-print',
    ],
  ];
}

/**
 * Implements hook_help().
 *
 * Provides module help text displayed on the Help page.
 *
 * @param string $route_name
 *   The route name of the current help page request.
 * @param \Drupal\Core\Routing\RouteMatchInterface $route_match
 *   The current route match object.
 *
 * @return \Drupal\Core\StringTranslation\TranslatableMarkup|null
 *   A translated help string for the module, or NULL if the route does not
 *   match this module's help page.
 */
function pdf_forge_help($route_name, RouteMatchInterface $route_match) {
  if ($route_name === 'help.page.pdf_forge') {
    return t('PDF Forge provides a service to render Drupal output to PDF using Dompdf, plus a demo hub page and settings UI.');
  }
  return NULL;
}
