<?php

namespace HelpGent\App\Providers;

defined( 'ABSPATH' ) || exit;

use HelpGent\App\Support\Element\Fields\Address;
use HelpGent\App\Support\Element\Fields\ContactInfo;
use HelpGent\App\Support\Element\Fields\DropDown;
use HelpGent\App\Support\Element\Fields\Email;
use HelpGent\App\Support\Element\Fields\LongText;
use HelpGent\App\Support\Element\Fields\Map;
use HelpGent\App\Support\Element\Fields\Number;
use HelpGent\App\Support\Element\Fields\Time;
use HelpGent\App\Support\Element\Fields\PhoneNumber;
use HelpGent\App\Support\Element\Fields\ShortText;
use HelpGent\App\Support\Element\Fields\SingleSelect;
use HelpGent\App\Support\Element\Fields\Website;
use HelpGent\App\Support\Element\Fields\YesNo;
use HelpGent\App\Support\Element\Fields\RatingStar;
use HelpGent\App\Support\Element\Fields\PromoterScore;
use HelpGent\WpMVC\Contracts\Provider;

class FieldServiceProvider implements Provider {
    public function boot() {
        add_filter( 'helpgent_allowed_elements_on_submission', [$this, 'allowed_elements_on_submission'] );
    }

    public function allowed_elements_on_submission( array $elements ) {
        return array_values(
            array_unique(
                array_merge(
                    $elements,
                    [
                        Address::get_key(),
                        ContactInfo::get_key(),
                        DropDown::get_key(),
                        Email::get_key(),
                        Number::get_key(),
                        LongText::get_key(),
                        PhoneNumber::get_key(),
                        ShortText::get_key(),
                        SingleSelect::get_key(),
                        Website::get_key(),
                        YesNo::get_key(),
                        Map::get_key(),
                        Time::get_key(),
                        RatingStar::get_key(),
                        PromoterScore::get_key(),
                    ]
                )
            )
        );
    }
}
