LSaddon::supann: add generate_supann_codeEtablissement_uai_nomenclature CLI command

This commit is contained in:
Benjamin Renard 2021-02-17 17:20:52 +01:00
parent 60eca6967c
commit 6b4bc036e3

View file

@ -572,3 +572,29 @@ function supannCheckEntityCouldBeDeleted($ldapObject) {
}
return true;
}
if (php_sapi_name() != 'cli')
return true;
function cli_generate_supann_codeEtablissement_uai_nomenclature($command_args) {
$data = file_get_contents('https://data.enseignementsup-recherche.gouv.fr/explore/dataset/fr-esr-principaux-etablissements-enseignement-superieur/download?format=json');
$items = json_decode($data, true);
if (!is_array($items))
LSlog :: fatal('Fail to retreive UAI dataset from data.enseignementsup-recherche.gouv.fr');
$codes = array();
foreach($items as $item) {
if (!isset($item['fields']) || !isset($item['fields']['uai']) || !$item['fields']['uai'])
continue;
$codes[$item['fields']['uai']] = $item['fields']['uo_lib'];
}
var_export($codes);
}
LScli :: add_command(
'generate_supann_codeEtablissement_uai_nomenclature',
'cli_generate_supann_codeEtablissement_uai_nomenclature',
'Generate Supann codeEtablissement UAI nomenclature',
false, // usage args
false, // long desc
false // need LDAP connection
);