<?php
/**
 * Footer renderer — presentation only.
 *
 * @package Kutby
 * @since   2.7.0
 */

declare(strict_types=1);

namespace Kutby\Footer\Services;

use Kutby\Events\Dispatcher;
use Kutby\Footer\Support\FooterContext;

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

/**
 * Class FooterRenderer
 */
final class FooterRenderer {

	/**
	 * Render the active footer layout.
	 *
	 * @return void
	 */
	public static function render(): void {
		$manager = new FooterManager();
		$layout  = $manager->layout();
		$ctx     = FooterContext::from_request();

		$layout->render( $ctx );

		Dispatcher::emit(
			'footer_rendered',
			array(
				'layout' => $layout->id(),
			)
		);
	}
}
