<?php

/**
 * Save an info popup entry.
 *
 * @param int $id - entry id
 * @param string $data - JSON encoded entry data
 * @return bool
 */

use QUI\InfoPopup\Handler;

QUI::getAjax()->registerFunction(
    'package_quiqqer_info-popup_ajax_save',
    function ($id, $data) {
        $data = json_decode($data, true);

        Handler::save((int)$id, is_array($data) ? $data : []);

        return true;
    },
    ['id', 'data'],
    'quiqqer.infoPopup.edit'
);
