ynh_extension_meeo/services/EleveManager.php

61 lines
No EOL
1.7 KiB
PHP

<?php
namespace YesWiki\Meeo\Service;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
use YesWiki\Bazar\Service\EntryManager;
use YesWiki\Bazar\Service\ListManager;
use YesWiki\Wiki;
use YesWiki\Meeo\Eleve\Eleve;
class EleveManager {
private $formId;
private $entryManager;
private $listManager;
private $wiki;
public function __construct( Wiki $wiki, ParameterBagInterface $params, EntryManager $entryManager, ListManager $listManager)
{
$meeo_config = $params->get('meeo');
$this->wiki = $wiki;
$this->formId = $meeo_config['elevesFormId'];
$this->entryManager = $entryManager;
$this->listManager = $listManager;
}
public function del($id) {
$this->entryManager->delete($id);
}
public function updateClasse($id, $classe) {
return $this->entryManager->update($id, ['listeListeClassesbf_classe' => $classe, 'antispam' => true]);
}
public function getAll() {
include 'tools/meeo/libs/eleves/eleve.lib.php';
$eleves = [];
foreach ($this->entryManager->search(['formsIds' => $this->formId]) as $data)
{
$eleve = new Eleve($this->entryManager, $data);
// echo "<p>".var_dump($eleve)."</p>";
$eleves[] = $eleve;
}
return $eleves;
}
public function getCurrentEleve(string $username) {
return $this->entryManager->getOne(str_replace(".","", $username));
}
public function view() {
$eleves = $this->getAll();
// echo '<p>'.var_dump($eleves).'</p>';
$classes = $this->listManager->getOne('ListeClasses');
// echo "<p>".var_dump($classes)."</p>";
return $this->wiki->render('@meeo/edu_eleves.twig', ['eleves' => $eleves, 'classes' => $classes['nodes']]);
}
}