<?php

namespace Blazemedia\Affiliation\Providers;

use Blazemedia\Affiliation\CustomPostTypes;
use Blazemedia\Affiliation\CustomTaxonomies;
use Blazemedia\Affiliation\AdminUserInterface\Settings\Capability;
use Blazemedia\Affiliation\API;

class CommonServiceProvider implements Contract\ServiceProviderInterface
{
    public function __construct() {
        
        $this->registerComponents();

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

    protected function getApis(): array
    {
        return [
            API\ArticlesByAsin::class,
            API\ArticlesByITM::class,
            API\Proxy::class,
        ];
    }

    protected function getComponents(): array
    {
    
        return [            
            CustomPostTypes\Zone::class,       /// definisce il post-type per le zone di affiliazione            
            /// che cosa sono queste tassonomie?
            CustomTaxonomies\BlzAffiliationAttributes::class,
            CustomTaxonomies\TrackingCustomer::class,            
        ];
    }



    protected function registerComponents(): void
    {
        foreach ($this->getComponents() as $component) {
            new $component();
        }
    }


    public function register(): void
    {
        Capability::getInstance('restrizioni_1');

        foreach ($this->getApis() as $api) {
            new $api();
        }
    }
}
