<?php

namespace Fab\Controller;

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

use Fab\Interfaces\JIT_Interface;

/**
 * FAB Type Toast.
 *
 * @package    Fab
 * @subpackage Fab/Module
 */
class Toast_Type extends Toast_Group implements JIT_Interface {

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

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

    /**
     * Add as recommended template.
     *
     * @param array $templates The templates.
     * @param int   $max_templates The max templates.
     * @return array
     */
    public function add_fab_dashboard_recommended_templates( $templates, $max_templates ) {
        // Check if max templates is reached.
        if ( count( $templates ) >= $max_templates ) {
            return $templates;
        }

        // Add as recommended template.
        $templates[] = 'latest-post-toast';
        $templates[] = 'welcome-toast';
        return $templates;
    }

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

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

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

        // Add as recommended template.
        add_filter( 'fab_dashboard_recommended_templates', array( __CLASS__, 'jit_add_fab_dashboard_recommended_templates' ), 10, 2 );
    }
}
