This commit is contained in:
2024-09-21 12:40:18 +02:00
parent 01f26e5463
commit 4eb9c95b1f
2699 changed files with 81 additions and 23031 deletions

View File

@ -54,7 +54,10 @@ class AppInitCommand extends Command
$output->writeln('APP = Default Data');
// Création du compte admin si non existant
$this->insertUser("admin","admin");
$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");
@ -536,24 +539,17 @@ class AppInitCommand extends Command
return Command::SUCCESS;
}
protected function insertUser() {
$metadata = $this->em->getClassMetaData('App:User');
$metadata->setIdGeneratorType(ClassMetadata::GENERATOR_TYPE_NONE);
$metadata->setIdGenerator(new AssignedGenerator());
// Création du compte admin par défaut
$entity = $this->em->getRepository('App:User')->findOneBy(["username"=>"admin"]);
protected function insertUser($username,$password,$firstname,$lastname,$email,$roles,$avatar) {
$entity = $this->em->getRepository('App:User')->findOneBy(["username"=>$username]);
if(!$entity) {
$this->writelnred('Création du compte admin par défaut avec password admin - Veuillez modifier votre password admin après connexion');
$entity = new User;
$entity->setId(-100);
$entity->setUsername("admin");
$entity->setPassword("admin");
$entity->setFirstname($this->appname);
$entity->setLastname("Admin");
$entity->setEmail($this->appmailnoreply);
$entity->setRoles(["ROLE_ADMIN"]);
$entity->setAvatar("admin.jpg");
$entity->setUsername($username);
$entity->setPassword($password);
$entity->setFirstname($firstname);
$entity->setLastname($lastname);
$entity->setEmail($email);
$entity->setRoles($roles);
$entity->setAvatar($avatar);
$this->em->persist($entity);
}
@ -588,7 +584,7 @@ class AppInitCommand extends Command
$this->em->flush();
}
protected function insertConfig($order,$category,$id,$title,$value,$type,$visible,$changeable,$required,$grouped,$help) {
private function insertConfig($order,$category,$id,$title,$value,$type,$visible,$changeable,$required,$grouped,$help) {
$entity=$this->em->getRepository("App:Config")->find($id);
if(!$entity) {
$entity= new Config();
@ -610,6 +606,43 @@ class AppInitCommand extends Command
$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");