<?php
// pages/components/newsletter_collection_modal.php
// Thin wrapper delegating to generic CRUD controller (Collections = NewsletterCampaigns)

use Components\Resources\Controllers\CrudController;
use Components\Models\NewsletterCampaign;

ob_start();

// Support presetting the archived toggle when creating from the Archive section empty state
$fieldPresets = [];
if ((int)\mh_get('preset_archived', 0, 'int') === 1) {
    $fieldPresets['newsletter_campaign_archived'] = 'True';
}
mh_load_modules_language_files(MH_DIR_MODULE, 'mb_newsletter');

echo CrudController::handle([
    'modelClass'    => NewsletterCampaign::class,
    'selfRoute'     => 'newsletter_collection_modal',
    'oobListRoute'  => 'newsletter_collection_list',
    'event_prefix'  => 'newsletter:campaigns',
    'field_presets' => $fieldPresets,
]);

$__html = ob_get_clean();
echo $__html;
