fix(manager): cs fixer
Cadoles/nineskeletor/pipeline/pr-master This commit looks good Details

This commit is contained in:
Arnaud Fornerot 2022-10-04 11:55:50 +02:00
parent 58518ec70d
commit 681b2f6547
6 changed files with 200 additions and 197 deletions

View File

@ -10,12 +10,12 @@ class HomeController extends AbstractController
{ {
public function home(Request $request): Response public function home(Request $request): Response
{ {
if ($request->getSession()->get('fgforceconnect')&&!$this->getUser()) { if ($request->getSession()->get('fgforceconnect') && !$this->getUser()) {
return $this->redirectToRoute('app_login'); return $this->redirectToRoute('app_login');
} }
if(!$this->getUser()) { if (!$this->getUser()) {
dump("here"); dump('here');
return $this->render('Home/home.html.twig', [ return $this->render('Home/home.html.twig', [
'useheader' => true, 'useheader' => true,
@ -24,22 +24,25 @@ class HomeController extends AbstractController
'maxsize' => 1000, 'maxsize' => 1000,
]); ]);
} }
if ($this->getUser()->hasRole("ROLE_USER")) if ($this->getUser()->hasRole('ROLE_USER')) {
return $this->redirectToRoute('app_user_home'); return $this->redirectToRoute('app_user_home');
}
if ($this->getUser()->hasRole("ROLE_MANAGER")) if ($this->getUser()->hasRole('ROLE_MANAGER')) {
return $this->redirectToRoute('app_manager_home'); return $this->redirectToRoute('app_manager_home');
}
if ($this->getUser()->hasRole("ROLE_MASTER")) if ($this->getUser()->hasRole('ROLE_MASTER')) {
return $this->redirectToRoute('app_master_home'); return $this->redirectToRoute('app_master_home');
}
if ($this->getUser()->hasRole("ROLE_MODO")) if ($this->getUser()->hasRole('ROLE_MODO')) {
return $this->redirectToRoute('app_modo_home'); return $this->redirectToRoute('app_modo_home');
}
if ($this->getUser()->hasRole("ROLE_ADMIN")) if ($this->getUser()->hasRole('ROLE_ADMIN')) {
return $this->redirectToRoute('app_admin_home'); return $this->redirectToRoute('app_admin_home');
}
} }
public function homeuser($access): Response public function homeuser($access): Response
@ -77,7 +80,6 @@ class HomeController extends AbstractController
return $this->redirectToRoute('app_admin_config'); return $this->redirectToRoute('app_admin_config');
} }
public function docrest(): Response public function docrest(): Response
{ {
return $this->render('Home/docrest.html.twig', [ return $this->render('Home/docrest.html.twig', [

View File

@ -79,7 +79,7 @@ class UserController extends AbstractController
break; break;
default: default:
$isactive = ($access=="manager"?$em->getRepository($this->entity)->getPreference($this->getUser(), 'userisactive', true):true); $isactive = ('manager' == $access ? $em->getRepository($this->entity)->getPreference($this->getUser(), 'userisactive', true) : true);
$niveau01 = $this->getUser()->getNiveau01(); $niveau01 = $this->getUser()->getNiveau01();
$niveau02 = $this->getUser()->getNiveau02(); $niveau02 = $this->getUser()->getNiveau02();
@ -300,13 +300,11 @@ class UserController extends AbstractController
$action .= "<a href='".$this->generateUrl(str_replace('_admin_', '_modo_', $this->route).'_update', ['id' => $data->getId()])."'><i class='fa fa-file fa-fw fa-2x'></i></a>"; $action .= "<a href='".$this->generateUrl(str_replace('_admin_', '_modo_', $this->route).'_update', ['id' => $data->getId()])."'><i class='fa fa-file fa-fw fa-2x'></i></a>";
break; break;
case 'manager': case 'manager':
if($this->getUser()->getNiveau03()&&$this->getUser()->getNiveau03()==$data->getNiveau03()) { if ($this->getUser()->getNiveau03() && $this->getUser()->getNiveau03() == $data->getNiveau03()) {
$action .= "<a href='".$this->generateUrl(str_replace('_admin_', '_manager_', $this->route).'_update', ['id' => $data->getId()])."'><i class='fa fa-file fa-fw fa-2x'></i></a>"; $action .= "<a href='".$this->generateUrl(str_replace('_admin_', '_manager_', $this->route).'_update', ['id' => $data->getId()])."'><i class='fa fa-file fa-fw fa-2x'></i></a>";
} } elseif (!$this->getUser()->getNiveau03() && $this->getUser()->getNiveau02() && $this->getUser()->getNiveau02() == $data->getNiveau02()) {
elseif(!$this->getUser()->getNiveau03()&&$this->getUser()->getNiveau02()&&$this->getUser()->getNiveau02()==$data->getNiveau02()) {
$action .= "<a href='".$this->generateUrl(str_replace('_admin_', '_manager_', $this->route).'_update', ['id' => $data->getId()])."'><i class='fa fa-file fa-fw fa-2x'></i></a>"; $action .= "<a href='".$this->generateUrl(str_replace('_admin_', '_manager_', $this->route).'_update', ['id' => $data->getId()])."'><i class='fa fa-file fa-fw fa-2x'></i></a>";
} } elseif (!$this->getUser()->getNiveau02() && $this->getUser()->getNiveau01() && $this->getUser()->getNiveau01() == $data->getNiveau01()) {
elseif(!$this->getUser()->getNiveau02()&&$this->getUser()->getNiveau01()&&$this->getUser()->getNiveau01()==$data->getNiveau01()) {
$action .= "<a href='".$this->generateUrl(str_replace('_admin_', '_manager_', $this->route).'_update', ['id' => $data->getId()])."'><i class='fa fa-file fa-fw fa-2x'></i></a>"; $action .= "<a href='".$this->generateUrl(str_replace('_admin_', '_manager_', $this->route).'_update', ['id' => $data->getId()])."'><i class='fa fa-file fa-fw fa-2x'></i></a>";
} }
break; break;
@ -394,11 +392,11 @@ class UserController extends AbstractController
$data->setApikey(Uuid::uuid4()); $data->setApikey(Uuid::uuid4());
// If manager set same niveau to usertosubmit // If manager set same niveau to usertosubmit
if($access=="manager") { if ('manager' == $access) {
$data->setNiveau01($this->getUser()->getNiveau01()); $data->setNiveau01($this->getUser()->getNiveau01());
$data->setNiveau02($this->getUser()->getNiveau02()); $data->setNiveau02($this->getUser()->getNiveau02());
$data->setNiveau03($this->getUser()->getNiveau03()); $data->setNiveau03($this->getUser()->getNiveau03());
$data->setRoles(["ROLE_USER"]); $data->setRoles(['ROLE_USER']);
} }
// Création du formulaire // Création du formulaire
@ -722,13 +720,11 @@ class UserController extends AbstractController
break; break;
case 'manager': case 'manager':
if($this->getUser()->getNiveau03()&&$this->getUser()->getNiveau03()==$entity->getNiveau03()) { if ($this->getUser()->getNiveau03() && $this->getUser()->getNiveau03() == $entity->getNiveau03()) {
return true; return true;
} } elseif ($this->getUser()->getNiveau02() && $this->getUser()->getNiveau02() == $entity->getNiveau02()) {
elseif($this->getUser()->getNiveau02()&&$this->getUser()->getNiveau02()==$entity->getNiveau02()) {
return true; return true;
} } elseif ($this->getUser()->getNiveau01() && $this->getUser()->getNiveau01() == $entity->getNiveau01()) {
elseif($this->getUser()->getNiveau01()&&$this->getUser()->getNiveau01()==$entity->getNiveau01()) {
return true; return true;
} }

View File

@ -2,22 +2,21 @@
namespace App\DataFixtures; namespace App\DataFixtures;
use Doctrine\Bundle\FixturesBundle\Fixture;
use Doctrine\Persistence\ObjectManager;
use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Component\HttpKernel\KernelInterface;
use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Output\BufferedOutput;
use Symfony\Component\Console\Output\ConsoleOutput;
use Doctrine\ORM\Id\AssignedGenerator;
use Doctrine\ORM\Mapping\ClassMetadata;
use App\Entity\Niveau01; use App\Entity\Niveau01;
use App\Entity\Niveau02; use App\Entity\Niveau02;
use App\Entity\Niveau03; use App\Entity\Niveau03;
use App\Entity\Niveau04; use App\Entity\Niveau04;
use App\Entity\User; use App\Entity\User;
use App\Entity\UserModo; use App\Entity\UserModo;
use Doctrine\Bundle\FixturesBundle\Fixture;
use Doctrine\ORM\Id\AssignedGenerator;
use Doctrine\ORM\Mapping\ClassMetadata;
use Doctrine\Persistence\ObjectManager;
use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Output\BufferedOutput;
use Symfony\Component\Console\Output\ConsoleOutput;
use Symfony\Component\HttpKernel\KernelInterface;
class AppFixtures extends Fixture class AppFixtures extends Fixture
{ {
@ -33,7 +32,7 @@ class AppFixtures extends Fixture
public function load(ObjectManager $manager): void public function load(ObjectManager $manager): void
{ {
// app:Init // app:Init
$this->writeln("app:Init"); $this->writeln('app:Init');
$application = new Application($this->kernel); $application = new Application($this->kernel);
$application->setAutoExit(false); $application->setAutoExit(false);
$input = new ArrayInput(['command' => 'app:Init']); $input = new ArrayInput(['command' => 'app:Init']);
@ -43,7 +42,7 @@ class AppFixtures extends Fixture
// app:Synchro // app:Synchro
$manager->clear(); $manager->clear();
$this->writeln("app:Synchro"); $this->writeln('app:Synchro');
$input = new ArrayInput(['command' => 'app:Synchro']); $input = new ArrayInput(['command' => 'app:Synchro']);
$boutput = new BufferedOutput(); $boutput = new BufferedOutput();
$application->run($input, $boutput); $application->run($input, $boutput);
@ -66,121 +65,124 @@ class AppFixtures extends Fixture
$metadata->setIdGenerator(new AssignedGenerator()); $metadata->setIdGenerator(new AssignedGenerator());
// Niveau 01 // Niveau 01
$this->writeln("Niveau01"); $this->writeln('Niveau01');
$csv = file_get_contents($this->kernel->getProjectDir().'/src/DataFixtures/niveau01.csv'); $csv = file_get_contents($this->kernel->getProjectDir().'/src/DataFixtures/niveau01.csv');
$tab = $this->csv_to_array($csv); $tab = $this->csv_to_array($csv);
foreach($tab as $lig) { foreach ($tab as $lig) {
$niveau01=$manager->getRepository('App\Entity\Niveau01')->find($lig['id']); $niveau01 = $manager->getRepository('App\Entity\Niveau01')->find($lig['id']);
if(!$niveau01) { if (!$niveau01) {
$niveau01=new Niveau01(); $niveau01 = new Niveau01();
$niveau01->setId($lig["id"]); $niveau01->setId($lig['id']);
$manager->persist($niveau01); $manager->persist($niveau01);
} }
$niveau01->setLabel($lig["label"]); $niveau01->setLabel($lig['label']);
$niveau01->setCode($lig["code"]); $niveau01->setCode($lig['code']);
$niveau01->setPostaladress($lig["postaladress"]); $niveau01->setPostaladress($lig['postaladress']);
$niveau01->setTelephonenumber($lig["telephonenumber"]); $niveau01->setTelephonenumber($lig['telephonenumber']);
$niveau01->setEmail($lig["email"]); $niveau01->setEmail($lig['email']);
$niveau01->setApikey($lig["apikey"]); $niveau01->setApikey($lig['apikey']);
$manager->flush(); $manager->flush();
} }
// Niveau 02 // Niveau 02
$this->writeln("Niveau02"); $this->writeln('Niveau02');
$csv = file_get_contents($this->kernel->getProjectDir().'/src/DataFixtures/niveau02.csv'); $csv = file_get_contents($this->kernel->getProjectDir().'/src/DataFixtures/niveau02.csv');
$tab = $this->csv_to_array($csv); $tab = $this->csv_to_array($csv);
foreach($tab as $lig) { foreach ($tab as $lig) {
$niveau01=$manager->getRepository('App\Entity\Niveau01')->findOneBy(["code"=>$lig['codenv1']]); $niveau01 = $manager->getRepository('App\Entity\Niveau01')->findOneBy(['code' => $lig['codenv1']]);
if(!$niveau01) continue; if (!$niveau01) {
continue;
$niveau02=$manager->getRepository('App\Entity\Niveau02')->find($lig['id']);
if(!$niveau02) {
$niveau02=new Niveau02();
$niveau02->setId($lig["id"]);
$manager->persist($niveau02);
} }
$niveau02->setLabel($lig["label"]);
$niveau02->setCode($lig["code"]); $niveau02 = $manager->getRepository('App\Entity\Niveau02')->find($lig['id']);
$niveau02->setPostaladress($lig["postaladress"]); if (!$niveau02) {
$niveau02->setTelephonenumber($lig["telephonenumber"]); $niveau02 = new Niveau02();
$niveau02->setEmail($lig["email"]); $niveau02->setId($lig['id']);
$niveau02->setApikey($lig["apikey"]); $manager->persist($niveau02);
}
$niveau02->setLabel($lig['label']);
$niveau02->setCode($lig['code']);
$niveau02->setPostaladress($lig['postaladress']);
$niveau02->setTelephonenumber($lig['telephonenumber']);
$niveau02->setEmail($lig['email']);
$niveau02->setApikey($lig['apikey']);
$niveau02->setNiveau01($niveau01); $niveau02->setNiveau01($niveau01);
$manager->flush(); $manager->flush();
} }
// Niveau 03 // Niveau 03
$this->writeln("Niveau03"); $this->writeln('Niveau03');
$csv = file_get_contents($this->kernel->getProjectDir().'/src/DataFixtures/niveau03.csv'); $csv = file_get_contents($this->kernel->getProjectDir().'/src/DataFixtures/niveau03.csv');
$tab = $this->csv_to_array($csv); $tab = $this->csv_to_array($csv);
foreach($tab as $lig) { foreach ($tab as $lig) {
$niveau02=$manager->getRepository('App\Entity\Niveau02')->findOneBy(["code"=>$lig['codenv2']]); $niveau02 = $manager->getRepository('App\Entity\Niveau02')->findOneBy(['code' => $lig['codenv2']]);
if(!$niveau02) continue; if (!$niveau02) {
continue;
$niveau03=$manager->getRepository('App\Entity\Niveau03')->find($lig['id']);
if(!$niveau03) {
$niveau03=new Niveau03();
$niveau03->setId($lig["id"]);
$manager->persist($niveau03);
} }
$niveau03->setLabel($lig["label"]);
$niveau03->setCode($lig["code"]); $niveau03 = $manager->getRepository('App\Entity\Niveau03')->find($lig['id']);
$niveau03->setPostaladress($lig["postaladress"]); if (!$niveau03) {
$niveau03->setTelephonenumber($lig["telephonenumber"]); $niveau03 = new Niveau03();
$niveau03->setEmail($lig["email"]); $niveau03->setId($lig['id']);
$niveau03->setApikey($lig["apikey"]); $manager->persist($niveau03);
}
$niveau03->setLabel($lig['label']);
$niveau03->setCode($lig['code']);
$niveau03->setPostaladress($lig['postaladress']);
$niveau03->setTelephonenumber($lig['telephonenumber']);
$niveau03->setEmail($lig['email']);
$niveau03->setApikey($lig['apikey']);
$niveau03->setNiveau02($niveau02); $niveau03->setNiveau02($niveau02);
$manager->flush(); $manager->flush();
} }
// Niveau 04 // Niveau 04
$this->writeln("Niveau04"); $this->writeln('Niveau04');
$csv = file_get_contents($this->kernel->getProjectDir().'/src/DataFixtures/niveau04.csv'); $csv = file_get_contents($this->kernel->getProjectDir().'/src/DataFixtures/niveau04.csv');
$tab = $this->csv_to_array($csv); $tab = $this->csv_to_array($csv);
foreach($tab as $lig) { foreach ($tab as $lig) {
$niveau03=$manager->getRepository('App\Entity\Niveau03')->findOneBy(["code"=>$lig['codenv3']]); $niveau03 = $manager->getRepository('App\Entity\Niveau03')->findOneBy(['code' => $lig['codenv3']]);
if(!$niveau03) continue; if (!$niveau03) {
continue;
}
$niveau04=$manager->getRepository('App\Entity\Niveau04')->find($lig['id']); $niveau04 = $manager->getRepository('App\Entity\Niveau04')->find($lig['id']);
if(!$niveau04) { if (!$niveau04) {
$niveau04=new Niveau04(); $niveau04 = new Niveau04();
$niveau04->setId($lig["id"]); $niveau04->setId($lig['id']);
$manager->persist($niveau04); $manager->persist($niveau04);
} }
$niveau04->setLabel($lig["label"]); $niveau04->setLabel($lig['label']);
$niveau04->setCode($lig["code"]); $niveau04->setCode($lig['code']);
$niveau04->setPostaladress($lig["postaladress"]); $niveau04->setPostaladress($lig['postaladress']);
$niveau04->setTelephonenumber($lig["telephonenumber"]); $niveau04->setTelephonenumber($lig['telephonenumber']);
$niveau04->setEmail($lig["email"]); $niveau04->setEmail($lig['email']);
$niveau04->setApikey($lig["apikey"]); $niveau04->setApikey($lig['apikey']);
$niveau04->setNiveau03($niveau03); $niveau04->setNiveau03($niveau03);
$manager->flush(); $manager->flush();
} }
// User MODO // User MODO
$this->writeln("User Modo"); $this->writeln('User Modo');
$userid=-99; $userid = -99;
$usercpt=0; $usercpt = 0;
$niveau01s=$manager->getRepository('App\Entity\Niveau01')->findAll(); $niveau01s = $manager->getRepository('App\Entity\Niveau01')->findAll();
foreach($niveau01s as $niveau01) { foreach ($niveau01s as $niveau01) {
$userid=$userid-1; $userid = $userid - 1;
$usercpt=$usercpt+1; $usercpt = $usercpt + 1;
$username="modo".str_pad($usercpt,3,"0", STR_PAD_LEFT); $username = 'modo'.str_pad($usercpt, 3, '0', STR_PAD_LEFT);
$user=$manager->getRepository('App\Entity\User')->find($userid); $user = $manager->getRepository('App\Entity\User')->find($userid);
if(!$user) { if (!$user) {
$user=new User(); $user = new User();
$user->setId($userid); $user->setId($userid);
$manager->persist($user); $manager->persist($user);
$usermodo=new UserModo(); $usermodo = new UserModo();
$usermodo->setUser($user); $usermodo->setUser($user);
$usermodo->setNiveau01($niveau01); $usermodo->setNiveau01($niveau01);
$manager->persist($usermodo); $manager->persist($usermodo);
@ -188,13 +190,13 @@ class AppFixtures extends Fixture
$user->setUsername($username); $user->setUsername($username);
$user->setPassword($username); $user->setPassword($username);
$user->setRoles(["ROLE_MODO"]); $user->setRoles(['ROLE_MODO']);
$user->setFirstname(str_pad($usercpt,3,"0", STR_PAD_LEFT)); $user->setFirstname(str_pad($usercpt, 3, '0', STR_PAD_LEFT));
$user->setLastname("Modo"); $user->setLastname('Modo');
$user->setEmail($username."@noreply.fr"); $user->setEmail($username.'@noreply.fr');
$user->setIsvisible(true); $user->setIsvisible(true);
$user->setIsactive(true); $user->setIsactive(true);
$user->setAvatar("noavatar.png"); $user->setAvatar('noavatar.png');
$user->setApikey($username); $user->setApikey($username);
$user->setNiveau01($niveau01); $user->setNiveau01($niveau01);
@ -202,31 +204,31 @@ class AppFixtures extends Fixture
} }
// User MASTER // User MASTER
$this->writeln("User Master"); $this->writeln('User Master');
$userid=-199; $userid = -199;
$usercpt=0; $usercpt = 0;
$niveau02s=$manager->getRepository('App\Entity\Niveau02')->findAll(); $niveau02s = $manager->getRepository('App\Entity\Niveau02')->findAll();
foreach($niveau02s as $niveau02) { foreach ($niveau02s as $niveau02) {
$userid=$userid-1; $userid = $userid - 1;
$usercpt=$usercpt+1; $usercpt = $usercpt + 1;
$username="master".str_pad($usercpt,3,"0", STR_PAD_LEFT); $username = 'master'.str_pad($usercpt, 3, '0', STR_PAD_LEFT);
$user=$manager->getRepository('App\Entity\User')->find($userid); $user = $manager->getRepository('App\Entity\User')->find($userid);
if(!$user) { if (!$user) {
$user=new User(); $user = new User();
$user->setId($userid); $user->setId($userid);
$manager->persist($user); $manager->persist($user);
} }
$user->setUsername($username); $user->setUsername($username);
$user->setPassword($username); $user->setPassword($username);
$user->setRoles(["ROLE_MASTER"]); $user->setRoles(['ROLE_MASTER']);
$user->setFirstname(str_pad($usercpt,3,"0", STR_PAD_LEFT)); $user->setFirstname(str_pad($usercpt, 3, '0', STR_PAD_LEFT));
$user->setLastname("Master"); $user->setLastname('Master');
$user->setEmail($username."@noreply.fr"); $user->setEmail($username.'@noreply.fr');
$user->setIsvisible(true); $user->setIsvisible(true);
$user->setIsactive(true); $user->setIsactive(true);
$user->setAvatar("noavatar.png"); $user->setAvatar('noavatar.png');
$user->setApikey($username); $user->setApikey($username);
$user->setNiveau01($niveau02->getNiveau01()); $user->setNiveau01($niveau02->getNiveau01());
$user->setNiveau02($niveau02); $user->setNiveau02($niveau02);
@ -235,31 +237,31 @@ class AppFixtures extends Fixture
} }
// User MANAGER // User MANAGER
$this->writeln("User Manager"); $this->writeln('User Manager');
$userid=-299; $userid = -299;
$usercpt=0; $usercpt = 0;
$niveau03s=$manager->getRepository('App\Entity\Niveau03')->findAll(); $niveau03s = $manager->getRepository('App\Entity\Niveau03')->findAll();
foreach($niveau03s as $niveau03) { foreach ($niveau03s as $niveau03) {
$userid=$userid-1; $userid = $userid - 1;
$usercpt=$usercpt+1; $usercpt = $usercpt + 1;
$username="manager".str_pad($usercpt,3,"0", STR_PAD_LEFT); $username = 'manager'.str_pad($usercpt, 3, '0', STR_PAD_LEFT);
$user=$manager->getRepository('App\Entity\User')->find($userid); $user = $manager->getRepository('App\Entity\User')->find($userid);
if(!$user) { if (!$user) {
$user=new User(); $user = new User();
$user->setId($userid); $user->setId($userid);
$manager->persist($user); $manager->persist($user);
} }
$user->setUsername($username); $user->setUsername($username);
$user->setPassword($username); $user->setPassword($username);
$user->setRoles(["ROLE_MANAGER"]); $user->setRoles(['ROLE_MANAGER']);
$user->setFirstname(str_pad($usercpt,3,"0", STR_PAD_LEFT)); $user->setFirstname(str_pad($usercpt, 3, '0', STR_PAD_LEFT));
$user->setLastname("Manager"); $user->setLastname('Manager');
$user->setEmail($username."@noreply.fr"); $user->setEmail($username.'@noreply.fr');
$user->setIsvisible(true); $user->setIsvisible(true);
$user->setIsactive(true); $user->setIsactive(true);
$user->setAvatar("noavatar.png"); $user->setAvatar('noavatar.png');
$user->setApikey($username); $user->setApikey($username);
$user->setNiveau01($niveau03->getNiveau02()->getNiveau01()); $user->setNiveau01($niveau03->getNiveau02()->getNiveau01());
$user->setNiveau02($niveau03->getNiveau02()); $user->setNiveau02($niveau03->getNiveau02());
@ -269,31 +271,31 @@ class AppFixtures extends Fixture
} }
// User USER // User USER
$this->writeln("User User"); $this->writeln('User User');
$userid=-399; $userid = -399;
$usercpt=0; $usercpt = 0;
$niveau03s=$manager->getRepository('App\Entity\Niveau03')->findAll(); $niveau03s = $manager->getRepository('App\Entity\Niveau03')->findAll();
foreach($niveau03s as $niveau03) { foreach ($niveau03s as $niveau03) {
$userid=$userid-1; $userid = $userid - 1;
$usercpt=$usercpt+1; $usercpt = $usercpt + 1;
$username="user".str_pad($usercpt,3,"0", STR_PAD_LEFT); $username = 'user'.str_pad($usercpt, 3, '0', STR_PAD_LEFT);
$user=$manager->getRepository('App\Entity\User')->find($userid); $user = $manager->getRepository('App\Entity\User')->find($userid);
if(!$user) { if (!$user) {
$user=new User(); $user = new User();
$user->setId($userid); $user->setId($userid);
$manager->persist($user); $manager->persist($user);
} }
$user->setUsername($username); $user->setUsername($username);
$user->setPassword($username); $user->setPassword($username);
$user->setRoles(["ROLE_USER"]); $user->setRoles(['ROLE_USER']);
$user->setFirstname(str_pad($usercpt,3,"0", STR_PAD_LEFT)); $user->setFirstname(str_pad($usercpt, 3, '0', STR_PAD_LEFT));
$user->setLastname("User"); $user->setLastname('User');
$user->setEmail($username."@noreply.fr"); $user->setEmail($username.'@noreply.fr');
$user->setIsvisible(true); $user->setIsvisible(true);
$user->setIsactive(true); $user->setIsactive(true);
$user->setAvatar("noavatar.png"); $user->setAvatar('noavatar.png');
$user->setApikey($username); $user->setApikey($username);
$user->setNiveau01($niveau03->getNiveau02()->getNiveau01()); $user->setNiveau01($niveau03->getNiveau02()->getNiveau01());
$user->setNiveau02($niveau03->getNiveau02()); $user->setNiveau02($niveau03->getNiveau02());
@ -304,31 +306,35 @@ class AppFixtures extends Fixture
// app:Synchro // app:Synchro
$manager->clear(); $manager->clear();
$this->writeln("app:Synchro"); $this->writeln('app:Synchro');
$input = new ArrayInput(['command' => 'app:Synchro']); $input = new ArrayInput(['command' => 'app:Synchro']);
$boutput = new BufferedOutput(); $boutput = new BufferedOutput();
$application->run($input, $boutput); $application->run($input, $boutput);
} }
private function writeln($string) { private function writeln($string)
{
$this->output->writeln(' <fg=yellow>></> <info>'.$string.'</info>'); $this->output->writeln(' <fg=yellow>></> <info>'.$string.'</info>');
} }
private function csv_to_array($csv, $delimiter = ';', $enclosure = '', $escape = '\\', $terminator = "\n")
private function csv_to_array($csv, $delimiter = ';', $enclosure = '', $escape = '\\', $terminator = "\n") { {
$r = array(); $r = [];
$rows = explode($terminator,trim($csv)); $rows = explode($terminator, trim($csv));
$names = array_shift($rows); $names = array_shift($rows);
$names = str_getcsv($names,$delimiter,$enclosure,$escape); $names = str_getcsv($names, $delimiter, $enclosure, $escape);
$nc = count($names); $nc = count($names);
foreach ($rows as $row) { foreach ($rows as $row) {
if (trim($row)) { if (trim($row)) {
$values = str_getcsv($row,$delimiter,$enclosure,$escape); $values = str_getcsv($row, $delimiter, $enclosure, $escape);
if (!$values) $values = array_fill(0,$nc,null); if (!$values) {
@$r[] = array_combine($names,$values); $values = array_fill(0, $nc, null);
}
@$r[] = array_combine($names, $values);
} }
} }
return $r; return $r;
} }
} }

View File

@ -181,7 +181,7 @@ class UserType extends AbstractType
); );
} }
if(($access!="all"&&$access!="manager")||$options["appUserviewisvisible"]) { if (('all' != $access && 'manager' != $access) || $options['appUserviewisvisible']) {
$choices = ['oui' => '1', 'non' => '0']; $choices = ['oui' => '1', 'non' => '0'];
$builder->add('isvisible', $builder->add('isvisible',
ChoiceType::class, [ ChoiceType::class, [

View File

@ -48,7 +48,6 @@ class AppSession
$session->set('fgheader', true); $session->set('fgheader', true);
$session->set('fgaudit', false); $session->set('fgaudit', false);
// Current user // Current user
$token = $this->token->getToken(); $token = $this->token->getToken();
if (!$token) { if (!$token) {