<?php

namespace WPT\Cf7Divi\Divi5\Modules\ContactForm7Module;

if ( !defined( 'ABSPATH' ) ) {
    die( 'Direct access forbidden.' );
}
require_once ABSPATH . 'wp-content/themes/Divi/includes/builder-5/server/Framework/Controllers/RESTController.php';
use WP_REST_Request;
use WP_REST_Response;
use ET\Builder\Framework\UserRole\UserRole;
use ET\Builder\Framework\Controllers\RESTController;
/**
 * Class for registering "Simple Quick Module"'s REST API Endpoint.
 */
class ContactForm7ModuleController extends RESTController {
    /**
     * Return unordered list of recent posts.
     */
    public static function index( WP_REST_Request $request ) : WP_REST_Response {
        $args = [
            'id' => $request->get_param( 'contactForm7Id' ),
        ];
        $response = [
            'html' => ContactForm7Module::render_contact_form7( $args ),
        ];
        return self::response_success( $response );
    }

    /**
     * Index action arguments.
     * Endpoint arguments as used in `register_rest_route()`.
     */
    public static function index_args() : array {
        return [];
    }

    /**
     * Index action permission.
     * Endpoint permission callback as used in `register_rest_route()`.
     */
    public static function index_permission() : bool {
        return UserRole::can_current_user_use_visual_builder();
    }

}
