Skip to content
Snippets Groups Projects
RegisteredMailController.php 828 B
Newer Older
  • Learn to ignore specific revisions
  • <?php
    
    /**
    * Copyright Maarch since 2008 under licence GPLv3.
    * See LICENCE.txt file at the root folder for more details.
    * This file is part of Maarch software.
    */
    
    /**
     * @brief Registered Mail Controller
     * @author dev@maarch.org
     */
    
    namespace RegisteredMail\controllers;
    
    use Slim\Http\Request;
    use Slim\Http\Response;
    
    class RegisteredMailController
    {
        public function getCountries(Request $request, Response $response)
        {
            $countries = [];
            if (($handle = fopen("referential/liste-197-etats.csv", "r")) !== FALSE) {
                fgetcsv($handle, 0, ';');
                while (($data = fgetcsv($handle, 0, ';')) !== FALSE) {
                    $countries[] = utf8_encode($data[0]);
                }
                fclose($handle);
            }
            return $response->withJson(['countries' => $countries]);
        }
    }