<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.

namespace local_kid\output;

use local_kid\local\niveau_repository;

defined('MOODLE_INTERNAL') || die();

class niveaux_admin_page implements \renderable, \templatable {

    public function export_for_template(\renderer_base $output): array {
        $niveaux = niveau_repository::get_all();

        $rows = [];
        foreach ($niveaux as $niveau) {
            $rows[] = [
                'code' => $niveau->code,
                'libelle' => format_string($niveau->libelle),
                'couleur' => $niveau->couleur,
                'sortorder' => $niveau->sortorder,
                'codeadesi' => $niveau->codeadesi,
                'renameurl' => (new \moodle_url('/local/kid/pages/niveau_edit.php', ['id' => $niveau->id]))->out(false),
            ];
        }

        return ['niveaux' => $rows];
    }
}
