diff --git a/commands/CreateFormsCommand.php b/commands/CreateFormsCommand.php index 0870da9..dbf35ef 100644 --- a/commands/CreateFormsCommand.php +++ b/commands/CreateFormsCommand.php @@ -9,6 +9,8 @@ use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; use YesWiki\Wiki; use YesWiki\Bazar\Service\FormManager; +use YesWiki\Core\Service\PageManager; +use YesWiki\Core\Service\TripleStore; use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; class CreateFormsCommand extends Command @@ -78,12 +80,28 @@ EOT, return $formManager->create($data); } + private function matiereList() + { + $pageManager = $this->wiki->services->get(PageManager::class); + $tripleStore = $this->wiki->services->get(TripleStore::class); + + if (!$pageManager->getOne('ListeMatiere')) { + $pageManager->save('ListeMatière', '{"label":{"francais":"Français","math":"Math"},"titre_liste":"Matieres"}'); + // in case, there is already some triples for 'ListOuinonLms', delete them + $tripleStore->delete('ListeMatière', 'http://outils-reseaux.org/_vocabulary/type', null); + // create the triple to specify this page is a list + $tripleStore->create('ListeMatière', 'http://outils-reseaux.org/_vocabulary/type', 'liste', '', ''); + } + } + private function notesForm(FormManager $formManager, $meeo_config) { $existingForm = $formManager->getOne($meeo_config['notes']['formId']); if ($existingForm) return false; + $this->matiereList(); + $data = [ "bn_id_nature" => $meeo_config['notes']['formId'], "bn_label_nature" => "Notes", @@ -94,8 +112,9 @@ EOT, "bn_sem_use_template" => "1", "bn_template" => << "fr-FR", @@ -108,7 +127,6 @@ EOT, protected function execute(InputInterface $input, OutputInterface $output) { - $formManager = $this->wiki->services->get(FormManager::class); $params = $this->wiki->services->get(ParameterBagInterface::class); if (!$params->has('meeo')) { @@ -116,22 +134,21 @@ EOT, $lastFormId = array_key_last($result); $meeo_config = [ 'absences' => [ - 'formId' => $lastFormId, + 'formId' => $lastFormId + 1, ], 'notes' => [ - 'formId' => $lastFormId + 1, + 'formId' => $lastFormId + 2, ] ]; } else { $meeo_config = $params->get('meeo'); } - if (!$this->absencesForm($formManager, $meeo_config)) - return Command::FAILURE; + $this->absencesForm($formManager, $meeo_config); - if (!$this->notesForm($formManager, $meeo_config)) - return Command::FAILURE; + $this->notesForm($formManager, $meeo_config); + echo 'Succeed\n'; return Command::SUCCESS; } }