<?php
namespace Elementor_Pay_Addons\Form;

if ( ! defined( 'ABSPATH' ) ) {
	exit; // Exit if accessed directly
}

use Elementor\Core\Base\Module;

// I want to store some registrars such as action, so we can add action into it and use it by a singleton like $actions = Module::instance()->actions_registrar->get();

class Registrar {
  private $items = [];

  public function register( $instance, $id = null ) {
		if ( $this->get( $id ) ) {
			return false;
		}

		$this->items[ $id ] = $instance;

		return true;
	}

	public function get( $id = null ) {
		if ( ! $id ) {
			return $this->items;
		}

		return isset( $this->items[ $id ] ) ? $this->items[ $id ] : null;
	}
}

class Form_Module extends Module {

  public $actions_registrar;

  public function __construct() {
    parent::__construct();
    $this->actions_registrar = new Registrar();
  }

  /**
   * Get module name.
   *
   * @return string
   */
  public function get_name() {
    return 'form-customize';
  }

  /**
   * Get the base URL for assets.
   *
   * @return string
   */
  public function get_assets_base_url(): string {
    return plugin_dir_url( __FILE__ ) . 'assets/';
  }
}