<?php

namespace Planaday\Html\Tags\Utility\StdNotice;

use Planaday\Html\Tags\Tag;
use Planaday\Utility\DependencyInjection\Container;
use Planaday\Utility\DependencyInjection\InjectionImpossibleException;

class StdNotice extends Tag {
	const TAG = 'std-notice';
	const DEFAULT_TEMPLATE = 'serverError';
	const SUBJECT_ATTRIBUTE = Tag::ATTRIBUTE_PREFIX . 'subject';

	/**
	 * @param Container $registry
	 *
	 * @throws InjectionImpossibleException
	 */
	public function __construct(Container $registry) {
		parent::__construct(__DIR__, self::DEFAULT_TEMPLATE, $registry);
	}

	public function buildTag(): string {
		$parser = $this->getNewParser();

		$subject = $this->attributes[self::SUBJECT_ATTRIBUTE] ?? null;
		$parser->setData('subject', $subject);

		return $parser->parse($this->getTemplate());
	}
}