<?php

namespace Planaday\Html\Tags\Form\Booking\AddressInput;

use Planaday\Entities\Booking\PostRequest\AddressFieldEnum;
use Planaday\Html\Tags\Form\SelectableDataInputFieldTag;
use Planaday\Utility\DependencyInjection\Container;
use Planaday\Utility\DependencyInjection\InjectionImpossibleException;

class AddressInput extends SelectableDataInputFieldTag {
	const TAG = 'address-input';
	const DEFAULT_TEMPLATE = 'addressInput';

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

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

		$parser->injectAttribute(
			$this->getRecursiveVersionOfAttribute(self::FIELD_CLASS_ATTRIBUTE),
			AddressFieldEnum::class
		);

		$parser->injectAttribute(
			self::FIELD_CLASS_ATTRIBUTE,
			AddressFieldEnum::class
		);

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