<?php
namespace Engine\Theme\JSLoader\Export;

/**
 * Export minimal app settings for legacy/non-MVC pages.
 * Emits DCsConfigs consumed by old modules outside MVC.
 */
class NonMVC extends AbstractExport
{
    public function rehashOutputFilename(array $hash): array
    {
        global $S, $CFG;
        $hash['dateStandard'] = $CFG['dateStandard']['default'];
        $hash['APP_URL'] = substr(md5(APP_URL), 0, 4);
        $hash['lang'] = $S['global']['lang'];
        return $hash;
    }

    public function gather(): static
    {
        global $S, $CFG;
        $this->data = [];
        $this->data['dateStandard'] =   $CFG['dateStandard']['default'];
        $this->data['lang'] =           $S['global']['lang'];
        $this->data['APP_URL'] =        APP_URL;
        $this->data['THEME_PATH'] =     \Theme::getInstance()->getUrl();
        return $this;
    }

    public function asJSON(): string
    {
        return $this->exportBulkVariables("DCsConfigs", $this->data);
    }
}
