<?php

/**
 * Instance of Shared for a Theme.
 *
 * @package northmill-online-shared
 *
 * @noinspection PhpUnused
 */
declare (strict_types=1);
namespace Northmill_Online_Shared_Checkout\Northmill_Online_Shared;

use Northmill_Online_Shared_Checkout\Northmill_Online_Shared\Modules\Info\Theme_Info_Module;
use Northmill_Online_Shared_Checkout\Northmill_Online_Shared\Modules\Updaters\Theme_Updater_Module;
/**
 * Class Theme_Shared
 */
abstract class Abstract_Theme_Shared extends Abstract_Shared_Base
{
    /**
     * The instance of the plugin shared class.
     *
     * @var Abstract_Theme_Shared
     */
    protected static Abstract_Theme_Shared $base_theme_instance;
    /**
     * The plugin info instance.
     *
     * @var Theme_Info_Module
     */
    public Theme_Info_Module $info;
    /**
     * Theme_Shared constructor.
     */
    final public function __construct()
    {
        self::$base_theme_instance = $this;
        parent::__construct();
        $this->setup_hooks(Theme_Info_Module::generate_underscored_service_name());
        $this->info = new Theme_Info_Module($this);
        $this->package_info = $this->info;
        $this->updater = new Theme_Updater_Module($this);
        // Mostly a placeholder for now.
        $this->post_construct();
        add_action('after_setup_theme', array($this, 'setup'), 1, 0);
        add_action('after_switch_theme', array($this, 'theme_activation'));
        add_action('switch_theme', array($this, 'theme_deactivation'));
    }
    /**
     * Code run on 'after_setup_theme'.
     *
     * @return void
     */
    final protected function internal_setup(): void
    {
        // TODO: Create theme updater.
    }
    /**
     * Run on theme activation.
     */
    final public function theme_activation(): void
    {
        $this->package_activation->package_activation();
    }
    /**
     * Run on theme deactivation.
     */
    final public function theme_deactivation(): void
    {
        $this->package_activation->package_deactivation();
    }
}
