<?php

namespace Fab\Controller;

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

use Fab\Helper\FABModal;
use Fab\Interfaces\JIT_Interface;

/**
 * Auth Login.
 *
 * @package    Fab
 * @subpackage Fab/Module
 */
class Auth_Login_Type extends Modal_Popup_Group implements JIT_Interface {

    /**
     * Constructor.
     */
    public function __construct() {
        parent::__construct();
        $this->type = 'auth_login';
    }

    /**
     * Get labels type.
     *
     * @return array
     */
    public function get_labels_type() {
        return array(
            'name' => __( 'Login', 'floating-awesome-button' ),
        );
    }

    /**
     * Add link data to FAB item
     *
     * @param object $instance FAB item instance.
     * @return void
     */
    public function add_fab_item_data( $instance ) {
        if ( $instance->getType() !== $this->type ) {
            return;
        }

        $modal = new FABModal( $instance->getID() );
        $instance->setModal( $modal );
    }

    /*
    |--------------------------------------------------------------------------
    | Fulfill implemented interface contracts
    |--------------------------------------------------------------------------
     */

    /**
     * JIT Method.
     *
     * @return void
     */
    public static function jit() {
        // Add group type.
        add_filter( 'fab_types_group_modal', array( __CLASS__, 'jit_add_fab_types_group' ), 10, 1 );

        // Adjust item data.
        add_action( 'fab_item_data', array( __CLASS__, 'jit_add_fab_item_data' ), 10, 1 );

        // Add fab setting types.
        add_filter( 'fab_setting_types', array( __CLASS__, 'jit_add_fab_setting_types' ), 10, 1 );
    }
}
