<?php

namespace Blazemedia\Affiliation\Providers;

use Blazemedia\Affiliation\AdminUserInterface\Buttons;
use Blazemedia\Affiliation\AdminUserInterface\Settings;
use Blazemedia\Affiliation\AdminUserInterface\MetaBoxes;
use Blazemedia\Affiliation\AdminUserInterface\Content;

class AdminServiceProvider implements Contract\ServiceProviderInterface
{
    public function __construct() {
		
		// Can register only in admin
		if ( !is_admin() || defined('DOING_CRON') ) return;

		add_action('init', [ $this, 'register'] );
	}


	protected function getSettings(): array
	{
		return [
			// gestione purge cache e transient
			Settings\CacheAndTransient::class,
			Settings\SettingPage::class,
			MetaBoxes\DisclaimerSettings::class,
			MetaBoxes\PaidSettings::class,
		];
	}

	

	protected function getButtons(): array
	{
		return [
		
			Buttons\AffiliateParseButton::class,
			Buttons\AffiliateParseCard::class,
			Buttons\AffiliateParseImage::class,
			Buttons\AffiliateButton::class,
			Buttons\AffiliateLink::class,
			Buttons\AffiliatePrice::class,
			Buttons\AffiliateTable::class,
			Buttons\AffiliateZone::class,
			Buttons\AffiliateWidget::class,
			Buttons\AffiliatePromo::class,
			Buttons\AffiliateBranded::class,
			Buttons\AffiliateParseCardAwin::class,
			
			Content\AsinChecker::class,			
		];
	}

    public function register() : void
    {		
		foreach ($this->getSettings() as $component) {
			new $component;
		}

		foreach ($this->getButtons() as $component) {
			new $component;
		}
    }
}
