multi user
This commit is contained in:
@ -53,22 +53,14 @@ class AppInitCommand extends Command
|
||||
|
||||
$output->writeln('APP = Default Data');
|
||||
|
||||
// Création du compte admin si non existant
|
||||
$this->insertUser("admin",$this->container->getParameter('appInitpwdadmin'),$this->appname,"Admin",$this->appmailnoreply,['ROLE_ADMIN'],"admin.jpg");
|
||||
|
||||
// Init Media
|
||||
//$this->initMedia();
|
||||
|
||||
// Création d'une catégory par défaut
|
||||
$this->insertCategory(-100,1,"Illustrations");
|
||||
|
||||
// colorbgbody = Couleur des fonds de page
|
||||
$this->insertConfig(
|
||||
1, // order
|
||||
false, // customizable
|
||||
"site", // category
|
||||
"appname", // id
|
||||
"Titre de votre site", // title
|
||||
"", // value
|
||||
$this->appname, // value
|
||||
"string", // type,
|
||||
true, // visible
|
||||
true, // changeable
|
||||
@ -79,10 +71,11 @@ class AppInitCommand extends Command
|
||||
|
||||
$this->insertConfig(
|
||||
2, // order
|
||||
true, // customizable
|
||||
"site", // category
|
||||
"appsubname", // id
|
||||
"Sous-titre de votre site", // title
|
||||
"", // value
|
||||
"Portefolio", // value
|
||||
"string", // type,
|
||||
true, // visible
|
||||
true, // changeable
|
||||
@ -93,6 +86,7 @@ class AppInitCommand extends Command
|
||||
|
||||
$this->insertConfig(
|
||||
3, // order
|
||||
true, // customizable
|
||||
"site", // category
|
||||
"appdescription", // id
|
||||
"Description de votre site", // title
|
||||
@ -107,6 +101,7 @@ class AppInitCommand extends Command
|
||||
|
||||
$this->insertConfig(
|
||||
4, // order
|
||||
false, // customizable
|
||||
"site", // category
|
||||
"appthumbwidth", // id
|
||||
"Largeur des miniatures", // title
|
||||
@ -121,6 +116,7 @@ class AppInitCommand extends Command
|
||||
|
||||
$this->insertConfig(
|
||||
5, // order
|
||||
false, // customizable
|
||||
"site", // category
|
||||
"appthumbheight", // id
|
||||
"Hauteur des miniatures", // title
|
||||
@ -135,6 +131,7 @@ class AppInitCommand extends Command
|
||||
|
||||
$this->insertConfig(
|
||||
6, // order
|
||||
false, // customizable
|
||||
"site", // category
|
||||
"appthumbfilter", // id
|
||||
"Filtre sur les miniatures", // title
|
||||
@ -149,7 +146,8 @@ class AppInitCommand extends Command
|
||||
|
||||
$this->insertConfig(
|
||||
7, // order
|
||||
"site", // category
|
||||
false, // customizable
|
||||
"false", // category
|
||||
"appthumbfiltergrayscale", // id
|
||||
"Filtre grayscale sur les miniatures", // title
|
||||
"100", // value
|
||||
@ -163,6 +161,7 @@ class AppInitCommand extends Command
|
||||
|
||||
$this->insertConfig(
|
||||
8, // order
|
||||
false, // customizable
|
||||
"site", // category
|
||||
"appthumbfilteropacity", // id
|
||||
"Filtre opacity sur les miniatures", // title
|
||||
@ -177,6 +176,7 @@ class AppInitCommand extends Command
|
||||
|
||||
$this->insertConfig(
|
||||
9, // order
|
||||
false, // customizable
|
||||
"site", // category
|
||||
"appthumbfiltersepia", // id
|
||||
"Filtre sepia sur les miniatures", // title
|
||||
@ -192,6 +192,7 @@ class AppInitCommand extends Command
|
||||
|
||||
$this->insertConfig(
|
||||
10, // order
|
||||
false, // customizable
|
||||
"site", // category
|
||||
"appmaxthumbwidth", // id
|
||||
"Largeur maximum de la grille des thumbs", // title
|
||||
@ -207,6 +208,7 @@ class AppInitCommand extends Command
|
||||
// colorbgbody = Couleur des fonds de page
|
||||
$this->insertConfig(
|
||||
1, // order
|
||||
false, // customizable
|
||||
"colorbgbody", // category
|
||||
"colorbgbodydark", // id
|
||||
"Couleur de fond fonçée", // title
|
||||
@ -221,6 +223,7 @@ class AppInitCommand extends Command
|
||||
|
||||
$this->insertConfig(
|
||||
2, // order
|
||||
false, // customizable
|
||||
"colorbgbody", // category
|
||||
"colorbgbodylight", // id
|
||||
"Couleur de fond claire", // title
|
||||
@ -236,6 +239,7 @@ class AppInitCommand extends Command
|
||||
// colorfttitle = Couleur des fontes titre
|
||||
$this->insertConfig(
|
||||
1, // order
|
||||
false, // customizable
|
||||
"colorfttitle", // category
|
||||
"colorfttitledark", // id
|
||||
"Couleur des titres sur fond fonçé", // title
|
||||
@ -250,6 +254,7 @@ class AppInitCommand extends Command
|
||||
|
||||
$this->insertConfig(
|
||||
2, // order
|
||||
false, // customizable
|
||||
"colorfttitle", // category
|
||||
"colorfttitlelight", // id
|
||||
"Couleur des titres sur fond claire", // title
|
||||
@ -265,6 +270,7 @@ class AppInitCommand extends Command
|
||||
// colorftbody = Couleur des fontes titre
|
||||
$this->insertConfig(
|
||||
1, // order
|
||||
false, // customizable
|
||||
"colorftbody", // category
|
||||
"colorftbodydark", // id
|
||||
"Couleur de la police sur fond fonçé", // title
|
||||
@ -279,6 +285,7 @@ class AppInitCommand extends Command
|
||||
|
||||
$this->insertConfig(
|
||||
2, // order
|
||||
false, // customizable
|
||||
"colorftbody", // category
|
||||
"colorftbodylight", // id
|
||||
"Couleur de la police sur fond claire", // title
|
||||
@ -294,6 +301,7 @@ class AppInitCommand extends Command
|
||||
// font = nom des polices
|
||||
$this->insertConfig(
|
||||
1, // order
|
||||
false, // customizable
|
||||
"font", // category
|
||||
"fonttitle", // id
|
||||
"Police pour les titres", // title
|
||||
@ -308,6 +316,7 @@ class AppInitCommand extends Command
|
||||
|
||||
$this->insertConfig(
|
||||
2, // order
|
||||
false, // customizable
|
||||
"font", // category
|
||||
"fontbody", // id
|
||||
"Police principale", // title
|
||||
@ -323,10 +332,11 @@ class AppInitCommand extends Command
|
||||
// logo =
|
||||
$this->insertConfig(
|
||||
1, // order
|
||||
false, // customizable
|
||||
"logo", // category
|
||||
"logodark", // id
|
||||
"Logo sur fond fonçé", // title
|
||||
"", // value
|
||||
"logo.png", // value
|
||||
"logo", // type,
|
||||
true, // visible
|
||||
true, // changeable
|
||||
@ -337,10 +347,11 @@ class AppInitCommand extends Command
|
||||
|
||||
$this->insertConfig(
|
||||
2, // order
|
||||
false, // customizable
|
||||
"logo", // category
|
||||
"logolight", // id
|
||||
"Logo sur fond clair", // title
|
||||
"", // value
|
||||
"logo.png", // value
|
||||
"logo", // type,
|
||||
true, // visible
|
||||
true, // changeable
|
||||
@ -352,10 +363,11 @@ class AppInitCommand extends Command
|
||||
// image =
|
||||
$this->insertConfig(
|
||||
1, // order
|
||||
true, // customizable
|
||||
"image", // category
|
||||
"imgcontact", // id
|
||||
"Image Contact", // title
|
||||
"", // value
|
||||
"contact.jpg", // value
|
||||
"image", // type,
|
||||
true, // visible
|
||||
true, // changeable
|
||||
@ -366,10 +378,11 @@ class AppInitCommand extends Command
|
||||
|
||||
$this->insertConfig(
|
||||
1, // order
|
||||
true, // customizable
|
||||
"image", // category
|
||||
"imglink", // id
|
||||
"Image Liens", // title
|
||||
"", // value
|
||||
"link.jpg", // value
|
||||
"image", // type,
|
||||
true, // visible
|
||||
true, // changeable
|
||||
@ -381,10 +394,11 @@ class AppInitCommand extends Command
|
||||
// hero =
|
||||
$this->insertConfig(
|
||||
1, // order
|
||||
true, // customizable
|
||||
"hero", // category
|
||||
"hero01", // id
|
||||
"Carrousel 01", // title
|
||||
"", // value
|
||||
"hero.jpg", // value
|
||||
"hero", // type,
|
||||
true, // visible
|
||||
true, // changeable
|
||||
@ -395,6 +409,7 @@ class AppInitCommand extends Command
|
||||
|
||||
$this->insertConfig(
|
||||
2, // order
|
||||
true, // customizable
|
||||
"hero", // category
|
||||
"hero02", // id
|
||||
"Carrousel 02", // title
|
||||
@ -409,6 +424,7 @@ class AppInitCommand extends Command
|
||||
|
||||
$this->insertConfig(
|
||||
3, // order
|
||||
true, // customizable
|
||||
"hero", // category
|
||||
"hero03", // id
|
||||
"Carrousel 03", // title
|
||||
@ -423,6 +439,7 @@ class AppInitCommand extends Command
|
||||
|
||||
$this->insertConfig(
|
||||
4, // order
|
||||
true, // customizable
|
||||
"hero", // category
|
||||
"hero04", // id
|
||||
"Carrousel 04", // title
|
||||
@ -437,6 +454,7 @@ class AppInitCommand extends Command
|
||||
|
||||
$this->insertConfig(
|
||||
5, // order
|
||||
true, // customizable
|
||||
"hero", // category
|
||||
"hero05", // id
|
||||
"Carrousel 05", // title
|
||||
@ -452,6 +470,7 @@ class AppInitCommand extends Command
|
||||
// Social =
|
||||
$this->insertConfig(
|
||||
1, // order
|
||||
false, // customizable
|
||||
"social", // category
|
||||
"email", // id
|
||||
"Email", // title
|
||||
@ -466,6 +485,7 @@ class AppInitCommand extends Command
|
||||
|
||||
$this->insertConfig(
|
||||
2, // order
|
||||
true, // customizable
|
||||
"social", // category
|
||||
"facebook", // id
|
||||
"Facebook", // title
|
||||
@ -480,6 +500,7 @@ class AppInitCommand extends Command
|
||||
|
||||
$this->insertConfig(
|
||||
3, // order
|
||||
true, // customizable
|
||||
"social", // category
|
||||
"instagram", // id
|
||||
"Instagram", // title
|
||||
@ -494,6 +515,7 @@ class AppInitCommand extends Command
|
||||
|
||||
$this->insertConfig(
|
||||
4, // order
|
||||
true, // customizable
|
||||
"social", // category
|
||||
"twitter", // id
|
||||
"Twitter", // title
|
||||
@ -508,6 +530,7 @@ class AppInitCommand extends Command
|
||||
|
||||
$this->insertConfig(
|
||||
5, // order
|
||||
true, // customizable
|
||||
"social", // category
|
||||
"google", // id
|
||||
"Google", // title
|
||||
@ -522,6 +545,7 @@ class AppInitCommand extends Command
|
||||
|
||||
$this->insertConfig(
|
||||
6, // order
|
||||
true, // customizable
|
||||
"social", // category
|
||||
"youtube", // id
|
||||
"Youtube", // title
|
||||
@ -534,6 +558,11 @@ class AppInitCommand extends Command
|
||||
"Le Youtube du site"
|
||||
);
|
||||
|
||||
|
||||
|
||||
// Création du compte admin si non existant
|
||||
$this->insertUser("admin",$this->container->getParameter('appInitpwdadmin'),$this->appname,"Admin",$this->appmailnoreply,['ROLE_ADMIN'],"admin.jpg");
|
||||
|
||||
$output->writeln('');
|
||||
|
||||
return Command::SUCCESS;
|
||||
@ -547,6 +576,7 @@ class AppInitCommand extends Command
|
||||
$entity->setPassword($password);
|
||||
$entity->setFirstname($firstname);
|
||||
$entity->setLastname($lastname);
|
||||
$entity->SetPseudo($username);
|
||||
$entity->setEmail($email);
|
||||
$entity->setRoles($roles);
|
||||
$entity->setAvatar($avatar);
|
||||
@ -557,41 +587,38 @@ class AppInitCommand extends Command
|
||||
$this->em->flush();
|
||||
}
|
||||
|
||||
protected function insertCategory($id,$order,$name) {
|
||||
$metadata = $this->em->getClassMetaData('App:Category');
|
||||
$metadata->setIdGeneratorType(ClassMetadata::GENERATOR_TYPE_NONE);
|
||||
$metadata->setIdGenerator(new AssignedGenerator());
|
||||
|
||||
// Création du compte admin par défaut
|
||||
$entity = $this->em->getRepository('App:Category')->find($id);
|
||||
if(!$entity) {
|
||||
$entity = new Category;
|
||||
$entity->setId($id);
|
||||
$entity->setOrder($order);
|
||||
$entity->setName($name);
|
||||
$entity->setUsecategoryconfig(false);
|
||||
$entity->setAppthumbfilter(false);
|
||||
$entity->setAppthumbheight(0);
|
||||
$entity->setAppthumbwidth(0);
|
||||
$entity->setAppthumbfilter(false);
|
||||
$entity->setAppthumbfiltergrayscale(100);
|
||||
$entity->setAppthumbfilteropacity(100);
|
||||
$entity->setAppthumbfiltersepia(0);
|
||||
$this->em->persist($entity);
|
||||
}
|
||||
protected function insertCategory($name) {
|
||||
|
||||
// On flush
|
||||
$this->em->flush();
|
||||
$users=$this->em->getRepository('App:User')->findAll();
|
||||
foreach($users as $user) {
|
||||
$category=$entity = $this->em->getRepository('App:Category')->findOneBy(["user"=>$user]);
|
||||
if(!$category) {
|
||||
$category = new Category;
|
||||
$category->setOrder(1);
|
||||
$category->setName($name);
|
||||
$category->setUsecategoryconfig(false);
|
||||
$category->setAppthumbfilter(false);
|
||||
$category->setAppthumbheight(0);
|
||||
$category->setAppthumbwidth(0);
|
||||
$category->setAppthumbfilter(false);
|
||||
$category->setAppthumbfiltergrayscale(100);
|
||||
$category->setAppthumbfilteropacity(100);
|
||||
$category->setAppthumbfiltersepia(0);
|
||||
$category->setUser($user);
|
||||
$this->em->persist($category);
|
||||
$this->em->flush();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function insertConfig($order,$category,$id,$title,$value,$type,$visible,$changeable,$required,$grouped,$help) {
|
||||
$entity=$this->em->getRepository("App:Config")->find($id);
|
||||
private function insertConfig($order,$customizable,$category,$key,$title,$value,$type,$visible,$changeable,$required,$grouped,$help) {
|
||||
$entity=$this->em->getRepository("App:Config")->findOneBy(["keyid"=>$key,"user"=>null]);
|
||||
if(!$entity) {
|
||||
$entity= new Config();
|
||||
$entity->setId($id);
|
||||
$entity->setValue($value);
|
||||
$entity->setKeyid($key);
|
||||
$entity->setUser(null);
|
||||
}
|
||||
|
||||
$entity->setDefvalue($value);
|
||||
$entity->setCategory($category);
|
||||
$entity->setOrder($order);
|
||||
$entity->setTitle($title);
|
||||
@ -601,48 +628,12 @@ class AppInitCommand extends Command
|
||||
$entity->setRequired($required);
|
||||
$entity->setGrouped($grouped);
|
||||
$entity->setHelp($help);
|
||||
$entity->setCustomizable($customizable&&$changeable&&$visible);
|
||||
|
||||
$this->em->persist($entity);
|
||||
$this->em->flush();
|
||||
}
|
||||
|
||||
private function initMedia() {
|
||||
// Initialiser Filesystem
|
||||
$filesystem = new Filesystem();
|
||||
|
||||
$sourcePath = $this->container->getParameter('kernel.project_dir') . '/public/styles/medias';
|
||||
$destinationPath = $this->container->getParameter('kernel.project_dir') . '/public/uploads';
|
||||
|
||||
echo "====================";
|
||||
echo get_current_user();
|
||||
|
||||
// Vérifier si le répertoire existe
|
||||
if (!$filesystem->exists($destinationPath."/logo")) {
|
||||
$filesystem->mkdir($destinationPath,0777);
|
||||
$filesystem->mkdir($destinationPath."/image",0777);
|
||||
$filesystem->mkdir($destinationPath."/logo",0777);
|
||||
$filesystem->mkdir($destinationPath."/avatar",0777);
|
||||
$filesystem->mkdir($destinationPath."/hero",0777);
|
||||
|
||||
$filesystem->chown($destinationPath, 'apache');
|
||||
$filesystem->chown($destinationPath."/image",'apache');
|
||||
$filesystem->chown($destinationPath."/logo",'apache');
|
||||
$filesystem->chown($destinationPath."/avatar",'apache');
|
||||
$filesystem->chown($destinationPath."/hero",'apache');
|
||||
}
|
||||
|
||||
/*
|
||||
$filesystem->copy($sourcePath."/admin.jpg", $destinationPath."/avatar/");
|
||||
$filesystem->copy($sourcePath."/noavatar.png", $destinationPath."/avatar/");
|
||||
$filesystem->copy($sourcePath."/system.jpg", $destinationPath."/avatar/");
|
||||
$filesystem->copy($sourcePath."/contact.jpg", $destinationPath."/image");
|
||||
$filesystem->copy($sourcePath."/link.jpg", $destinationPath."/image");
|
||||
$filesystem->copy($sourcePath."/hero.jpg", $destinationPath."/hero");
|
||||
$filesystem->copy($sourcePath."/logo.png", $destinationPath."/logo");
|
||||
*/
|
||||
echo "====================";
|
||||
}
|
||||
|
||||
private function writelnred($string) {
|
||||
$this->output->writeln('<fg=red>'.$string.'</>');
|
||||
$this->filesystem->appendToFile($this->rootlog.'cron.log', $string."\n");
|
||||
|
@ -20,32 +20,53 @@ class ConfigController extends AbstractController
|
||||
public function list()
|
||||
{
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$datas = $em->getRepository($this->entity)->findBy(["visible"=>true]);
|
||||
$datas = $em->getRepository($this->entity)->findBy(["visible"=>true,"user"=>null]);
|
||||
|
||||
return $this->render($this->render.'list.html.twig',[
|
||||
$this->data."s" => $datas,
|
||||
"useheader" => true,
|
||||
"usesidebar" => true,
|
||||
"mode" => "config",
|
||||
]);
|
||||
}
|
||||
|
||||
public function listrender($category)
|
||||
public function listrender($mode,$category,$userid)
|
||||
{
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$datas = $em->getRepository($this->entity)->findBy(["visible"=>true,"category"=>$category]);
|
||||
$user=null;
|
||||
if($userid) $user=$em->getRepository("App:User")->find($userid);
|
||||
$datas = $em->getRepository($this->entity)->findBy(["visible"=>true,"category"=>$category,"user"=>$user]);
|
||||
|
||||
return $this->render($this->render.'render.html.twig',[
|
||||
$this->data."s" => $datas,
|
||||
"useheader" => true,
|
||||
"usesidebar" => true,
|
||||
"mode" => $mode,
|
||||
"userid" => $userid,
|
||||
]);
|
||||
}
|
||||
|
||||
public function update($id,Request $request)
|
||||
public function listuserrender($mode,$category)
|
||||
{
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$datas = $em->getRepository($this->entity)->findBy(["visible"=>true,"category"=>$category,"user"=>$this->getUser()]);
|
||||
|
||||
return $this->render($this->render.'render.html.twig',[
|
||||
$this->data."s" => $datas,
|
||||
"useheader" => true,
|
||||
"usesidebar" => true,
|
||||
"mode" => $mode,
|
||||
]);
|
||||
}
|
||||
|
||||
public function update($mode,$id,$userid,Request $request)
|
||||
{
|
||||
// Initialisation de l'enregistrement
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$data=$em->getRepository($this->entity)->find($id);
|
||||
|
||||
$user=null;
|
||||
if($mode!="config") $user=$em->getRepository("App:User")->find($userid);
|
||||
$data=$em->getRepository($this->entity)->findOneBy(["id"=>$id,"user"=>$user]);
|
||||
|
||||
// Création du formulaire
|
||||
$form = $this->createForm(Form::class,$data,array("mode"=>"update","id"=>$data->getId(),"type"=>$data->getType(),"required"=>$data->getRequired()));
|
||||
@ -63,7 +84,12 @@ class ConfigController extends AbstractController
|
||||
$em->flush();
|
||||
|
||||
// Retour à la liste
|
||||
return $this->redirectToRoute($this->route);
|
||||
if($mode!="config") {
|
||||
return $this->redirectToRoute("app_user_update",["id"=>$userid]);
|
||||
}
|
||||
else {
|
||||
return $this->redirectToRoute($this->route);
|
||||
}
|
||||
}
|
||||
|
||||
// Affichage du formulaire
|
||||
@ -71,23 +97,76 @@ class ConfigController extends AbstractController
|
||||
'useheader' => true,
|
||||
'usesidebar' => true,
|
||||
$this->data => $data,
|
||||
'mode' => 'update',
|
||||
'form' => $form->createView()
|
||||
'mode' => $mode,
|
||||
'form' => $form->createView(),
|
||||
'userid' => $userid,
|
||||
]);
|
||||
}
|
||||
|
||||
public function delete($id,Request $request)
|
||||
public function updateuser($mode,$id,Request $request)
|
||||
{
|
||||
// Initialisation de l'enregistrement
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$data=$em->getRepository($this->entity)->findOneBy(["id"=>$id,"user"=>$this->getUser()]);
|
||||
|
||||
// Création du formulaire
|
||||
$form = $this->createForm(Form::class,$data,array("mode"=>"update","id"=>$data->getId(),"type"=>$data->getType(),"required"=>$data->getRequired()));
|
||||
|
||||
// Récupération des data du formulaire
|
||||
$form->handleRequest($request);
|
||||
|
||||
// Sur erreur
|
||||
$this->getErrorForm($id,$form,$request,$data,"update");
|
||||
|
||||
// Sur validation
|
||||
if ($form->get('submit')->isClicked() && $form->isValid()) {
|
||||
$data = $form->getData();
|
||||
$em->persist($data);
|
||||
$em->flush();
|
||||
|
||||
// Retour à la liste
|
||||
return $this->redirectToRoute("app_user_profil");
|
||||
}
|
||||
|
||||
// Affichage du formulaire
|
||||
return $this->render($this->render.'edit.html.twig', [
|
||||
'useheader' => true,
|
||||
'usesidebar' => false,
|
||||
$this->data => $data,
|
||||
'mode' => $mode,
|
||||
'form' => $form->createView(),
|
||||
'userid' => $this->getUser()->getId(),
|
||||
]);
|
||||
}
|
||||
|
||||
public function delete($mode,$id,$userid,Request $request)
|
||||
{
|
||||
// Récupération de l'enregistrement courant
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$config=$em->getRepository($this->entity)->find($id);
|
||||
if(!$config->getRequired()) {
|
||||
$config->setValue("");
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$em->persist($config);
|
||||
$em->flush();
|
||||
$config=$em->getRepository($this->entity)->find(["id"=>$id]);
|
||||
$config->setValue(null);
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$em->persist($config);
|
||||
$em->flush();
|
||||
// Retour à la liste
|
||||
if($mode!="config") {
|
||||
return $this->redirectToRoute("app_user_update",["id"=>$userid]);
|
||||
}
|
||||
return $this->redirectToRoute('app_config');
|
||||
else {
|
||||
return $this->redirectToRoute($this->route);
|
||||
}
|
||||
}
|
||||
|
||||
public function deleteuser($id,Request $request)
|
||||
{
|
||||
// Récupération de l'enregistrement courant
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$config=$em->getRepository($this->entity)->findOneBy(["id"=>$id,"user"=>$this->getUser()]);
|
||||
$config->setValue(null);
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$em->persist($config);
|
||||
$em->flush();
|
||||
return $this->redirectToRoute('app_user_profil');
|
||||
}
|
||||
|
||||
public function logo()
|
||||
|
@ -12,20 +12,47 @@ class HomeController extends AbstractController
|
||||
public function home()
|
||||
{
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$categorys = $em->getRepository("App:Category")->findAll();
|
||||
$links = $em->getRepository("App:Link")->findAll();
|
||||
$webzines = $em->getRepository("App:Webzine")->findBy([], ['set' => 'ASC', 'order' => 'ASC']);
|
||||
|
||||
$users = $em->getRepository("App:User")->findBy([],["pseudo"=>"ASC"]);
|
||||
$categorys = $em->getRepository("App:Category")->findBy(["user"=>null]);
|
||||
$links = $em->getRepository("App:Link")->findBy(["user"=>null]);
|
||||
$webzines = $em->getRepository("App:Webzine")->findBy(["user"=>null], ['set' => 'ASC', 'order' => 'ASC']);
|
||||
|
||||
return $this->render('Home/home.html.twig',[
|
||||
"useheader" => false,
|
||||
"usesidebar" => false,
|
||||
"usemonocolor" => true,
|
||||
"users" => $users,
|
||||
"categorys" => $categorys,
|
||||
"links" => $links,
|
||||
"webzines" => $webzines
|
||||
]);
|
||||
}
|
||||
|
||||
public function user($userpseudo)
|
||||
{
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$user=$em->getRepository("App:User")->findOneBy(["slug"=>$userpseudo]);
|
||||
if(!$user) return $this->redirectToRoute("app_home");
|
||||
|
||||
$categorys = $em->getRepository("App:Category")->findBy(["user"=>$user]);
|
||||
$links = $em->getRepository("App:Link")->findBy(["user"=>$user]);
|
||||
$webzines = $em->getRepository("App:Webzine")->findBy(["user"=>$user], ['set' => 'ASC', 'order' => 'ASC']);
|
||||
$config = $em->getRepository("App:Config")->getUserConfig($user);
|
||||
|
||||
return $this->render('Home/user.html.twig',[
|
||||
"useheader" => false,
|
||||
"usesidebar" => false,
|
||||
"usemonocolor" => true,
|
||||
"user" => $user,
|
||||
"config" => $config,
|
||||
"categorys" => $categorys,
|
||||
"links" => $links,
|
||||
"webzines" => $webzines
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
public function feed($nb)
|
||||
{
|
||||
$feeds=[];
|
||||
|
@ -82,6 +82,7 @@ class SecurityController extends AbstractController
|
||||
$user->setUsername($username);
|
||||
$user->setLastname($lastname);
|
||||
$user->setFirstname($firstname);
|
||||
$user->setPseudo($username);
|
||||
$user->setEmail($email);
|
||||
|
||||
$user->setPassword("CASPWD-".$username);
|
||||
@ -158,5 +159,5 @@ class SecurityController extends AbstractController
|
||||
\phpCAS::logout(array("service"=>$url));
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -157,7 +157,7 @@ class UserController extends AbstractController
|
||||
$em->flush();
|
||||
|
||||
// Retour à la liste
|
||||
return $this->redirectToRoute("app_home");
|
||||
return $this->redirectToRoute("app_home_user",["userpseudo"=>$data->getPseudo()]);
|
||||
}
|
||||
|
||||
// Affichage du formulaire
|
||||
|
@ -66,6 +66,11 @@ class Category
|
||||
*/
|
||||
private $appthumbfiltersepia;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="User")
|
||||
*/
|
||||
private $user;
|
||||
|
||||
/**
|
||||
* @ORM\OneToMany(targetEntity="Illustration", mappedBy="category", cascade={"persist", "remove"}, orphanRemoval=true)
|
||||
* @ORM\OrderBy({"id" = "DESC"})
|
||||
@ -227,4 +232,16 @@ class Category
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getUser(): ?User
|
||||
{
|
||||
return $this->user;
|
||||
}
|
||||
|
||||
public function setUser(?User $user): self
|
||||
{
|
||||
$this->user = $user;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -7,15 +7,22 @@ use Doctrine\ORM\Mapping as ORM;
|
||||
/**
|
||||
* Cron
|
||||
*
|
||||
* @ORM\Table(name="config")
|
||||
* @ORM\Table(name="config",uniqueConstraints={@ORM\UniqueConstraint(name="configkeyid", columns={"keyid","user_id"})})
|
||||
* @ORM\Entity(repositoryClass="App\Repository\ConfigRepository")
|
||||
*/
|
||||
class Config
|
||||
{ /**
|
||||
{
|
||||
/**
|
||||
* @ORM\Column(name="id", type="integer")
|
||||
* @ORM\Id
|
||||
* @ORM\Column(type="string")
|
||||
* @ORM\GeneratedValue(strategy="AUTO")
|
||||
*/
|
||||
protected $id;
|
||||
private $id;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string", length=250)
|
||||
*/
|
||||
protected $keyid;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string", length=250)
|
||||
@ -23,10 +30,15 @@ class Config
|
||||
protected $title;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="text")
|
||||
* @ORM\Column(type="text", nullable=true)
|
||||
*/
|
||||
protected $value;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="text", nullable=true)
|
||||
*/
|
||||
protected $defvalue;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="roworder", type="string")
|
||||
*/
|
||||
@ -67,30 +79,69 @@ class Config
|
||||
*/
|
||||
protected $help;
|
||||
|
||||
public function getId(): ?string
|
||||
/**
|
||||
* @ORM\Column(type="boolean")
|
||||
*/
|
||||
protected $customizable;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="User")
|
||||
*/
|
||||
private $user;
|
||||
|
||||
public function getId(): ?int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function setId(string $id): self
|
||||
public function getKeyid(): ?string
|
||||
{
|
||||
$this->id = $id;
|
||||
return $this->keyid;
|
||||
}
|
||||
|
||||
public function setKeyid(string $keyid): self
|
||||
{
|
||||
$this->keyid = $keyid;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getTitle(): ?string
|
||||
{
|
||||
return $this->title;
|
||||
}
|
||||
|
||||
public function setTitle(string $title): self
|
||||
{
|
||||
$this->title = $title;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getValue(): ?string
|
||||
{
|
||||
return $this->value;
|
||||
return ($this->value?$this->value:($this->user?null:$this->defvalue));
|
||||
}
|
||||
|
||||
public function setValue(string $value): self
|
||||
public function setValue(?string $value): self
|
||||
{
|
||||
$this->value = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getDefvalue(): ?string
|
||||
{
|
||||
return $this->defvalue;
|
||||
}
|
||||
|
||||
public function setDefvalue(?string $defvalue): self
|
||||
{
|
||||
$this->defvalue = $defvalue;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getOrder(): ?string
|
||||
{
|
||||
return $this->order;
|
||||
@ -187,14 +238,26 @@ class Config
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getTitle(): ?string
|
||||
public function getCustomizable(): ?bool
|
||||
{
|
||||
return $this->title;
|
||||
return $this->customizable;
|
||||
}
|
||||
|
||||
public function setTitle(string $title): self
|
||||
public function setCustomizable(bool $customizable): self
|
||||
{
|
||||
$this->title = $title;
|
||||
$this->customizable = $customizable;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getUser(): ?User
|
||||
{
|
||||
return $this->user;
|
||||
}
|
||||
|
||||
public function setUser(?User $user): self
|
||||
{
|
||||
$this->user = $user;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
@ -36,6 +36,11 @@ class Link
|
||||
*/
|
||||
protected $url;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="User")
|
||||
*/
|
||||
private $user;
|
||||
|
||||
public function getId(): ?int
|
||||
{
|
||||
return $this->id;
|
||||
@ -77,4 +82,16 @@ class Link
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getUser(): ?User
|
||||
{
|
||||
return $this->user;
|
||||
}
|
||||
|
||||
public function setUser(?User $user): self
|
||||
{
|
||||
$this->user = $user;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -14,7 +14,9 @@ use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
|
||||
*
|
||||
* @ORM\Entity(repositoryClass="App\Repository\UserRepository")
|
||||
* @ORM\Table(name="user",uniqueConstraints={@ORM\UniqueConstraint(name="username", columns={"username"})})
|
||||
* @ORM\Table(name="user",uniqueConstraints={@ORM\UniqueConstraint(name="pseudo", columns={"pseudo"})})
|
||||
* @UniqueEntity("username", message="Ce nom d'utilisateur existe dèja")
|
||||
* @UniqueEntity("pseudo", message="Ce pseudo d'utilisateur existe dèja")
|
||||
*/
|
||||
|
||||
class User implements UserInterface, \Serializable
|
||||
@ -65,6 +67,16 @@ class User implements UserInterface, \Serializable
|
||||
private $lastname;
|
||||
private $displayname;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string", length=250)
|
||||
*/
|
||||
private $pseudo;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string", length=250)
|
||||
*/
|
||||
private $slug;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string", length=200, nullable=true, options={"default" : 0})
|
||||
*/
|
||||
@ -84,11 +96,29 @@ class User implements UserInterface, \Serializable
|
||||
*/
|
||||
private $groups;
|
||||
|
||||
/**
|
||||
* @ORM\OneToMany(targetEntity="Category", mappedBy="user", cascade={"persist", "remove"}, orphanRemoval=true)
|
||||
*/
|
||||
private $illustrations;
|
||||
|
||||
/**
|
||||
* @ORM\OneToMany(targetEntity="Webzine", mappedBy="user", cascade={"persist", "remove"}, orphanRemoval=true)
|
||||
*/
|
||||
private $webzines;
|
||||
|
||||
/**
|
||||
* @ORM\OneToMany(targetEntity="Link", mappedBy="user", cascade={"persist", "remove"}, orphanRemoval=true)
|
||||
*/
|
||||
private $links;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->groups = new ArrayCollection();
|
||||
$this->surveys = new ArrayCollection();
|
||||
$this->guests = new ArrayCollection();
|
||||
$this->illustrations = new ArrayCollection();
|
||||
$this->webzines = new ArrayCollection();
|
||||
$this->links = new ArrayCollection();
|
||||
}
|
||||
|
||||
public function getUsername(): ?string
|
||||
@ -267,4 +297,120 @@ class User implements UserInterface, \Serializable
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection|Category[]
|
||||
*/
|
||||
public function getIllustrations(): Collection
|
||||
{
|
||||
return $this->illustrations;
|
||||
}
|
||||
|
||||
public function addIllustration(Category $illustration): self
|
||||
{
|
||||
if (!$this->illustrations->contains($illustration)) {
|
||||
$this->illustrations[] = $illustration;
|
||||
$illustration->setUser($this);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function removeIllustration(Category $illustration): self
|
||||
{
|
||||
if ($this->illustrations->removeElement($illustration)) {
|
||||
// set the owning side to null (unless already changed)
|
||||
if ($illustration->getUser() === $this) {
|
||||
$illustration->setUser(null);
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection|Webzine[]
|
||||
*/
|
||||
public function getWebzines(): Collection
|
||||
{
|
||||
return $this->webzines;
|
||||
}
|
||||
|
||||
public function addWebzine(Webzine $webzine): self
|
||||
{
|
||||
if (!$this->webzines->contains($webzine)) {
|
||||
$this->webzines[] = $webzine;
|
||||
$webzine->setUser($this);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function removeWebzine(Webzine $webzine): self
|
||||
{
|
||||
if ($this->webzines->removeElement($webzine)) {
|
||||
// set the owning side to null (unless already changed)
|
||||
if ($webzine->getUser() === $this) {
|
||||
$webzine->setUser(null);
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection|Link[]
|
||||
*/
|
||||
public function getLinks(): Collection
|
||||
{
|
||||
return $this->links;
|
||||
}
|
||||
|
||||
public function addLink(Link $link): self
|
||||
{
|
||||
if (!$this->links->contains($link)) {
|
||||
$this->links[] = $link;
|
||||
$link->setUser($this);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function removeLink(Link $link): self
|
||||
{
|
||||
if ($this->links->removeElement($link)) {
|
||||
// set the owning side to null (unless already changed)
|
||||
if ($link->getUser() === $this) {
|
||||
$link->setUser(null);
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getPseudo(): ?string
|
||||
{
|
||||
return $this->pseudo;
|
||||
}
|
||||
|
||||
public function setPseudo(?string $pseudo): self
|
||||
{
|
||||
$this->pseudo = $pseudo;
|
||||
$pseudo=strtolower($pseudo);
|
||||
if($pseudo=="admin"||$pseudo=="user"||$pseudo=="feed"||$pseudo=="_uploader") $pseudo.="home";
|
||||
$this->slug = $pseudo;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getSlug(): ?string
|
||||
{
|
||||
return $this->slug;
|
||||
}
|
||||
|
||||
public function setSlug(string $slug): self
|
||||
{
|
||||
$this->slug = $slug;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
@ -50,7 +50,12 @@ class Webzine
|
||||
* @ORM\Column(type="integer")
|
||||
*/
|
||||
private $mode;
|
||||
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="User")
|
||||
*/
|
||||
private $user;
|
||||
|
||||
/**
|
||||
* @ORM\OneToMany(targetEntity="Webzinepage", mappedBy="webzine", cascade={"persist", "remove"}, orphanRemoval=true)
|
||||
* @ORM\OrderBy({"order" = "ASC"})
|
||||
@ -169,4 +174,16 @@ class Webzine
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getUser(): ?User
|
||||
{
|
||||
return $this->user;
|
||||
}
|
||||
|
||||
public function setUser(?User $user): self
|
||||
{
|
||||
$this->user = $user;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ class ConfigType extends AbstractType
|
||||
array("label" => "Valider",
|
||||
"attr" => array("class" => "btn btn-success")));
|
||||
|
||||
$builder->add('id',
|
||||
$builder->add('keyid',
|
||||
TextType::class,
|
||||
array("label" =>"Clé",
|
||||
"label_attr" => array("style" => 'margin-top:15px;'),
|
||||
|
@ -42,11 +42,15 @@ class UserType extends AbstractType
|
||||
]
|
||||
);
|
||||
|
||||
$builder->add('pseudo',
|
||||
TextType::class, [
|
||||
"label" =>"Pseudo",
|
||||
]
|
||||
);
|
||||
|
||||
if($options["mode"]!="profil") {
|
||||
$choices=[];
|
||||
$choices['Administrateur']='ROLE_ADMIN';
|
||||
$choices['Modérateur']='ROLE_MODO';
|
||||
$choices['Master']='ROLE_MASTER';
|
||||
$choices['Utilisateur']='ROLE_USER';
|
||||
|
||||
$builder->add('roles',
|
||||
|
@ -3,6 +3,7 @@
|
||||
namespace App\Repository;
|
||||
|
||||
use App\Entity\Config;
|
||||
use App\Entity\User;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Common\Persistence\ManagerRegistry;
|
||||
|
||||
@ -12,4 +13,28 @@ class ConfigRepository extends ServiceEntityRepository
|
||||
{
|
||||
parent::__construct($registry, Config::class);
|
||||
}
|
||||
|
||||
public function getUserConfig(User $user): array {
|
||||
$tbconfig=[];
|
||||
$custos=$this->_em->getRepository('App:Config')->findBy(["user"=>$user]);
|
||||
foreach($custos as $custo) {
|
||||
if($custo->getValue()) {
|
||||
$tbcusto[$custo->getKeyid()]=$custo->getValue();
|
||||
}
|
||||
else {
|
||||
// On va prendre la valeur global pour les category hero et image
|
||||
if($custo->getCategory()=="image"||$custo->getCategory()=="hero") {
|
||||
$config=$this->_em->getRepository('App:Config')->findOneBy(["keyid"=>$custo->getKeyid(),"user"=>null]);
|
||||
if($config) {
|
||||
$tbcusto[$custo->getKeyid()]=$config->getValue();
|
||||
}
|
||||
}
|
||||
// Sinon clé vide
|
||||
else {
|
||||
$tbcusto[$custo->getKeyid()]=null;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $tbcusto;
|
||||
}
|
||||
}
|
||||
|
108
src/Service/UserSubscriber.php
Executable file
108
src/Service/UserSubscriber.php
Executable file
@ -0,0 +1,108 @@
|
||||
<?php
|
||||
|
||||
namespace App\Service;
|
||||
|
||||
use App\Entity\User;
|
||||
use App\Entity\UserGroup;
|
||||
use App\Entity\Category;
|
||||
use App\Entity\Config;
|
||||
use Doctrine\Bundle\DoctrineBundle\EventSubscriber\EventSubscriberInterface;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Doctrine\ORM\Events;
|
||||
use Doctrine\Persistence\Event\LifecycleEventArgs;
|
||||
use Ramsey\Uuid\Uuid;
|
||||
|
||||
class UserSubscriber implements EventSubscriberInterface
|
||||
{
|
||||
private $em;
|
||||
private $user;
|
||||
|
||||
public function __construct(EntityManagerInterface $em)
|
||||
{
|
||||
$this->em = $em;
|
||||
}
|
||||
|
||||
public function getSubscribedEvents(): array
|
||||
{
|
||||
return [
|
||||
Events::postPersist,
|
||||
Events::postUpdate,
|
||||
];
|
||||
}
|
||||
|
||||
public function postPersist(LifecycleEventArgs $args): void
|
||||
{
|
||||
$this->upinsertUser($args);
|
||||
}
|
||||
|
||||
public function postUpdate(LifecycleEventArgs $args): void
|
||||
{
|
||||
$this->upinsertUser($args);
|
||||
}
|
||||
|
||||
private function upinsertUser(LifecycleEventArgs $args): void {
|
||||
$this->user = $args->getObject();
|
||||
if (!$this->user instanceof User) {
|
||||
return;
|
||||
}
|
||||
|
||||
// On s'assure que le user a au moins une category d'illustration
|
||||
$this->insertCategory();
|
||||
|
||||
// On initialise l'ensemble des config customizable
|
||||
$this->insertConfig();
|
||||
|
||||
}
|
||||
|
||||
private function insertCategory(): void {
|
||||
$user=$this->user;
|
||||
$category=$entity = $this->em->getRepository('App:Category')->findOneBy(["user"=>$this->user]);
|
||||
if(!$category) {
|
||||
$category = new Category;
|
||||
$category->setOrder(1);
|
||||
$category->setName("Illustrations");
|
||||
$category->setUsecategoryconfig(false);
|
||||
$category->setAppthumbfilter(false);
|
||||
$category->setAppthumbheight(0);
|
||||
$category->setAppthumbwidth(0);
|
||||
$category->setAppthumbfilter(false);
|
||||
$category->setAppthumbfiltergrayscale(100);
|
||||
$category->setAppthumbfilteropacity(100);
|
||||
$category->setAppthumbfiltersepia(0);
|
||||
$category->setUser($this->user);
|
||||
$this->em->persist($category);
|
||||
$this->em->flush();
|
||||
$this->user=$user;
|
||||
}
|
||||
dump($this->user);
|
||||
}
|
||||
|
||||
private function insertConfig(): void {
|
||||
$user=$this->user;
|
||||
$configs=$entity = $this->em->getRepository('App:Config')->findBy(["user"=>null,"customizable"=>true]);
|
||||
foreach($configs as $config) {
|
||||
$custo=$this->em->getRepository('App:Config')->findBy(["user"=>$user,"keyid"=>$config->getKeyid()]);
|
||||
if(!$custo) {
|
||||
$custo=new Config;
|
||||
$custo->setKeyid($config->getKeyid());
|
||||
$custo->setValue(null);
|
||||
$custo->setDefvalue(null);
|
||||
$custo->setCategory($config->getCategory());
|
||||
$custo->setOrder($config->getOrder());
|
||||
$custo->setTitle($config->getTitle());
|
||||
$custo->setType($config->getType());
|
||||
$custo->setVisible($config->getVisible());
|
||||
$custo->setChangeable($config->getChangeable());
|
||||
$custo->setRequired($config->getRequired());
|
||||
$custo->setGrouped($config->getGrouped());
|
||||
$custo->setHelp($config->getHelp());
|
||||
$custo->setCustomizable($config->getCustomizable());
|
||||
$custo->setUser($user);
|
||||
|
||||
$this->em->persist($custo);
|
||||
$this->em->flush();
|
||||
$this->user=$user;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,60 +1,25 @@
|
||||
<?php
|
||||
namespace App\Service;
|
||||
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
use Symfony\Component\HttpKernel\Event\RequestEvent;
|
||||
use Symfony\Component\HttpFoundation\Session\Session;
|
||||
use Doctrine\ORM\EntityManager;
|
||||
|
||||
class sessionInit {
|
||||
private $container;
|
||||
protected $em;
|
||||
protected $session;
|
||||
|
||||
public function __construct(ContainerInterface $container, EntityManager $em,Session $session)
|
||||
public function __construct(EntityManager $em, Session $session)
|
||||
{
|
||||
$this->container = $container;
|
||||
$this->session = $session;
|
||||
$this->em = $em;
|
||||
}
|
||||
|
||||
public function onDomainParse(RequestEvent $event) {
|
||||
$configs = $this->em->getRepository("App:Config")->findAll();
|
||||
$havehero=false;
|
||||
public function onDomainParse(RequestEvent $event): void
|
||||
{
|
||||
$configs = $this->em->getRepository("App:Config")->findBy(["user"=>null]);
|
||||
foreach($configs as $config) {
|
||||
if($config->getCategory()=="hero" && $config->getValue()!="") $havehero=true;
|
||||
$this->session->set($config->getId(), strval($config->getValue()));
|
||||
$this->session->set($config->getKeyid(), strval($config->getValue()));
|
||||
}
|
||||
|
||||
// Valeur par défaut appname
|
||||
if($this->session->get("appname")=="")
|
||||
$this->session->set("appname", $this->container->getParameter('appName'));
|
||||
|
||||
// Valeur par defaut hero
|
||||
if(!$havehero) $this->session->set("hero01", "hero.jpg");
|
||||
|
||||
// Valeur par defaut logo
|
||||
if($this->session->get("logodark")==""&&$this->session->get("logolight")=="") {
|
||||
$this->session->set("logodark", "logo.png");
|
||||
$this->session->set("logolight", "logo.png");
|
||||
}
|
||||
elseif($this->session->get("logodark")=="")
|
||||
$this->session->set("logodark", $this->session->get("logolight"));
|
||||
elseif($this->session->get("logolight")=="")
|
||||
$this->session->set("logolight", $this->session->get("logodark"));
|
||||
|
||||
// Valeur par défaut imgcontact
|
||||
if($this->session->get("imgcontact")=="")
|
||||
$this->session->set("imgcontact", "contact.jpg");
|
||||
|
||||
// Valeur par défaut imglink
|
||||
if($this->session->get("imglink")=="")
|
||||
$this->session->set("imglink", "link.jpg");
|
||||
|
||||
// Calcul des couleurs
|
||||
/*
|
||||
$color = $this->container->get('cadoles.core.service.color');
|
||||
$color->setColor();
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user