<?php

namespace Planaday\Html\NodeTags\Admin\Page\Logs;

use Planaday\Html\NodeTags\Tag;
use Planaday\Html\NodeTags\TemplateOnlyTag;
use Planaday\Platform\PlatformAbstraction\DataHandler;
use Planaday\Platform\PlatformAbstraction\UrlHandler;
use Planaday\Utility\Debug\Log\ErrorLogFileReader;
use Planaday\Utility\DependencyInjection\Attributes\Transient;

#[Transient]
class Logs implements Tag {
	use TemplateOnlyTag;

	public function __construct(
		protected UrlHandler $urlHandler,
		protected DataHandler $dataHandler,
		protected ErrorLogFileReader $errorLogFileReader
	) {}

	protected function prepareData( $nodeData ): void {
		$nodeData->data["restNonceHeader"] = fn() => json_encode($this->dataHandler->getRestNonceHeader());
		$nodeData->data["years"] = fn () => $this->errorLogFileReader->getFiles();
	}

	public function getTagDir(): string {
		return __DIR__;
	}
}