nineskeletor/src/Command/InitCommand.php

839 lines
42 KiB
PHP
Executable File

<?php
namespace App\Command;
use App\Entity\Config;
use App\Entity\Cron;
use App\Entity\Group;
use App\Entity\Icon;
use App\Entity\Niveau01;
use App\Entity\Page;
use App\Entity\Pagecategory;
use App\Entity\Pagewidget;
use App\Entity\User;
use App\Entity\Widget;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\Id\AssignedGenerator;
use Doctrine\ORM\Mapping\ClassMetadata;
use Ramsey\Uuid\Uuid;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\Finder\Finder;
class InitCommand extends Command
{
private $container;
private $em;
private $output;
private $filesystem;
private $rootlog;
private $appname;
public function __construct(ContainerInterface $container, EntityManagerInterface $em)
{
parent::__construct();
$this->container = $container;
$this->em = $em;
}
protected function configure()
{
$this
->setName('app:Init')
->setDescription('Init Data for App')
->setHelp('This command Init Data App')
;
}
protected function execute(InputInterface $input, OutputInterface $output)
{
$this->output = $output;
$this->filesystem = new Filesystem();
$this->rootlog = $this->container->get('kernel')->getLogDir().'/';
$this->appname = $this->container->getParameter('appName');
$this->writeln('APP = Default Data');
$metadata = $this->em->getClassMetaData('App\Entity\Group');
$metadata->setIdGeneratorType(ClassMetadata::GENERATOR_TYPE_NONE);
$metadata->setIdGenerator(new AssignedGenerator());
$metadata = $this->em->getClassMetaData('App\Entity\Niveau01');
$metadata->setIdGeneratorType(ClassMetadata::GENERATOR_TYPE_NONE);
$metadata->setIdGenerator(new AssignedGenerator());
$metadata = $this->em->getClassMetaData('App\Entity\User');
$metadata->setIdGeneratorType(ClassMetadata::GENERATOR_TYPE_NONE);
$metadata->setIdGenerator(new AssignedGenerator());
$metadata = $this->em->getClassMetaData('App\Entity\Page');
$metadata->setIdGeneratorType(ClassMetadata::GENERATOR_TYPE_NONE);
$metadata->setIdGenerator(new AssignedGenerator());
$metadata = $this->em->getClassMetaData('App\Entity\Pagecategory');
$metadata->setIdGeneratorType(ClassMetadata::GENERATOR_TYPE_NONE);
$metadata->setIdGenerator(new AssignedGenerator());
$metadata = $this->em->getClassMetaData('App\Entity\Pagewidget');
$metadata->setIdGeneratorType(ClassMetadata::GENERATOR_TYPE_NONE);
$metadata->setIdGenerator(new AssignedGenerator());
$metadata = $this->em->getClassMetaData('App\Entity\Widget');
$metadata->setIdGeneratorType(ClassMetadata::GENERATOR_TYPE_NONE);
$metadata->setIdGenerator(new AssignedGenerator());
// == ORGANISATION ========================================================================================================================================
// On s'assure que le groupe tout le monde existe
$group = $this->em->getRepository('App\Entity\Group')->findOneBy(['id' => '-1']);
if (!$group) {
$group = new Group();
$group->setId(-1);
$group->setLabel('Tout le monde');
$group->setIsopen(false);
$group->setIsworkgroup(false);
$group->setApikey(Uuid::uuid4());
$this->em->persist($group);
$this->em->flush();
}
// On s'assure qu'il exite un niveau01
$niveau01 = $this->em->getRepository('App\Entity\Niveau01')->findOneBy(['id' => '-1']);
if (!$niveau01) {
$niveau01 = new Niveau01();
$niveau01->setId(-1);
$niveau01->setLabel($this->appname);
$niveau01->setApikey(Uuid::uuid4());
$this->em->persist($niveau01);
$this->em->flush();
}
// On s'assure que le user admin existe
$user = $this->em->getRepository('App\Entity\User')->findOneBy(['id' => '-1']);
if (!$user) {
$user = new User();
$user->setId(-1);
$user->setUsername('admin');
$user->setFirstname('admin');
$user->setLastname($this->appname);
$user->setPassword($this->container->getParameter('appSecret'));
$user->setEmail($this->container->getParameter('appMailnoreply'));
$user->setApikey(Uuid::uuid4());
$user->setAvatar('admin.jpg');
$user->setIsVisible(true);
$user->setIsActive(true);
$user->setNiveau01($niveau01);
$this->em->persist($user);
$this->em->flush();
}
// On s'assure que les appAdmins sont bien admin
foreach ($this->container->getParameter('appAdmins') as $admin) {
$user = $this->em->getRepository('App\Entity\User')->findOneBy(['username' => $admin]);
if ($user && !$user->hasRole('ROLE_ADMIN')) {
$user->setRole('ROLE_ADMIN');
$this->em->flush();
}
}
// == CONFIG ==============================================================================================================================================
// colorbgbody = Couleur des fonds de page
$this->insertConfig(
1, // order
'site', // category
'appname', // id
'Titre de votre site', // title
'', // value
$this->appname, // default
'string', // type,
true, // visible
true, // changeable
false, // required
'', // grouped
'Titre de votre site'
);
$this->insertConfig(
2, // order
'site', // category
'appsubname', // id
'Sous-titre de votre site', // title
'', // value
'', // default
'string', // type,
true, // visible
true, // changeable
false, // required
'', // grouped
'Sous-titre de votre site'
);
$this->insertConfig(
3, // order
'site', // category
'appdescription', // id
'Description de votre site', // title
'', // value
'', // default
'editor', // type,
true, // visible
true, // changeable
false, // required
'', // grouped
'Description de votre site'
);
$this->insertConfig(
100, // order
'site', // category
'fgforceconnect', // id
'Forcer la connexion', // title
'', // value
'0', // default
'boolean', // type,
true, // visible
true, // changeable
true, // required
'', // grouped
'Forcer la connexion afin de rendre votre site privé'
);
$this->insertConfig(
500, // order
'site', // category
'apptheme', // id
'Thème de votre site', // title
'', // value
'', // default
'string', // type,
false, // visible
true, // changeable
false, // required
'', // grouped
'Thème de votre site'
);
// colorbgbody = Couleur des fonds de page
$this->insertConfig(
1, // order
'colorbgbody', // category
'colorbgbodydark', // id
'Couleur de fond fonçée', // title
'', // value
'#2e3131', // default
'color', // type,
true, // visible
true, // changeable
false, // required
'', // grouped
"La couleur de fond quand le site a besoin d'avoir une couleur de fond foncée"
);
$this->insertConfig(
2, // order
'colorbgbody', // category
'colorbgbodylight', // id
'Couleur de fond claire', // title
'', // value
'#ffffff', // default
'color', // type,
true, // visible
true, // changeable
false, // required
'', // grouped
"La couleur de fond quand le site a besoin d'avoir une couleur de fond claire"
);
// colorfttitle = Couleur des fontes titre
$this->insertConfig(
1, // order
'colorfttitle', // category
'colorfttitledark', // id
'Couleur des titres sur fond fonçé', // title
'', // value
'#ffffff', // default
'color', // type,
true, // visible
true, // changeable
false, // required
'', // grouped
'La couleur des titres sur fond fonçé'
);
$this->insertConfig(
2, // order
'colorfttitle', // category
'colorfttitlelight', // id
'Couleur des titres sur fond claire', // title
'', // value
'#2e3131', // default
'color', // type,
true, // visible
true, // changeable
false, // required
'', // grouped
'La couleur des titres sur fond claire'
);
// colorftbody = Couleur des fontes titre
$this->insertConfig(
1, // order
'colorftbody', // category
'colorftbodydark', // id
'Couleur de la police sur fond fonçé', // title
'', // value
'#ffffff', // default
'color', // type,
true, // visible
true, // changeable
false, // required
'', // grouped
'La couleur de la police sur fond fonçé'
);
$this->insertConfig(
2, // order
'colorftbody', // category
'colorftbodylight', // id
'Couleur de la police sur fond claire', // title
'', // value
'#343a40', // default
'color', // type,
true, // visible
true, // changeable
false, // required
'', // grouped
'La couleur de la police sur fond claire'
);
// font = nom des polices
$this->insertConfig(
1, // order
'font', // category
'fonttitle', // id
'Police pour les titres', // title
'', // value
'Theboldfont', // default
'font', // type,
true, // visible
true, // changeable
false, // required
'', // grouped
'La couleur de la police de votre site'
);
$this->insertConfig(
2, // order
'font', // category
'fontbody', // id
'Police principale', // title
'', // value
'Roboto-Regular', // default
'font', // type,
true, // visible
true, // changeable
false, // required
'', // grouped
'Nom de la police principale'
);
$this->insertConfig(
3, // order
'font', // category
'fontsizeh1', // id
'Taille des titres h1', // title
'', // value
'40', // default
'integer', // type,
true, // visible
true, // changeable
false, // required
'', // grouped
'Taille des titres h1 en px'
);
$this->insertConfig(
4, // order
'font', // category
'fontsizeh2', // id
'Taille des titres h2', // title
'', // value
'32', // default
'integer', // type,
true, // visible
true, // changeable
false, // required
'', // grouped
'Taille des titres h2 en px'
);
$this->insertConfig(
5, // order
'font', // category
'fontsizeh3', // id
'Taille des titres h3', // title
'', // value
'28', // default
'integer', // type,
true, // visible
true, // changeable
false, // required
'', // grouped
'Taille des titres h3 en px'
);
$this->insertConfig(
6, // order
'font', // category
'fontsizeh4', // id
'Taille des titres h4', // title
'', // value
'24', // default
'integer', // type,
true, // visible
true, // changeable
false, // required
'', // grouped
'Taille des titres h4 en px'
);
// logo =
$this->insertConfig(
1, // order
'logo', // category
'logodark', // id
'Logo sur fond fonçé', // title
'', // value
'logo.png', // default
'logo', // type,
true, // visible
true, // changeable
false, // required
'', // grouped
'Logo sur fond fonçé'
);
$this->insertConfig(
2, // order
'logo', // category
'logolight', // id
'Logo sur fond clair', // title
'', // value
'logo.png', // default
'logo', // type,
true, // visible
true, // changeable
false, // required
'', // grouped
'Logo sur fond clair'
);
// header =
$this->insertConfig(
1, // order
'header', // category
'headerimage', // id
'Image de fond de la bannière', // title
'', // value
'header.jpg', // default
'header', // type,
true, // visible
true, // changeable
false, // required
'', // grouped
'Image appnamede fond de la bannière'
);
$this->insertConfig(
1, // order
'header', // category
'headerheight', // id
'Hauteur de la bannière', // title
'', // value
'100', // default
'integer', // type,
true, // visible
true, // changeable
false, // required
'', // grouped
'Image de fond de la bannière'
);
// == CRON ================================================================================================================================================
// Job synchronisation des comptes utilisateur
// Toute les 24h à 3h00
$entity = $this->em->getRepository('App\Entity\Cron')->findOneBy(['command' => 'app:Synchro']);
if (!$entity) {
$entity = new Cron();
$nextdate = $entity->getSubmitdate();
$nextdate->setTime(4, 0);
$entity->setCommand('app:Synchro');
$entity->setDescription('Synchronisation des comptes utilisateurs');
$entity->setStatut(1);
$entity->setRepeatinterval(86400);
$entity->setNextexecdate($nextdate);
$this->em->persist($entity);
}
// Job purge des registrations obsolètes
// Toute les 5mn
$entity = $this->em->getRepository('App\Entity\Cron')->findOneBy(['command' => 'app:CleanRegistration']);
if (!$entity) {
$entity = new Cron();
$entity->setCommand('app:CleanRegistration');
$entity->setDescription('Nettoyage des Inscriptions obsolètes');
$entity->setStatut(1);
$entity->setRepeatinterval(300);
$entity->setNextexecdate($entity->getSubmitdate());
$this->em->persist($entity);
}
$this->em->flush();
// == ICON ================================================================================================================================================
$finder = new Finder();
$finder->in('public/medias/icon/');
$finder->name('icon_*');
foreach ($finder as $file) {
$image = 'icon/'.$file->getRelativePathname();
$icon = $this->em->getRepository('App\Entity\Icon')->findoneby(['label' => $image]);
if (!$icon) {
$icon = new Icon();
$icon->setLabel($image);
$this->em->persist($icon);
}
}
$this->em->flush();
// == PAGECATEGORY ========================================================================================================================================
$entityPagecategory = $this->em->getRepository('App\Entity\Pagecategory')->find(1);
if (!$entityPagecategory) {
$entityPagecategory = new Pagecategory();
$entityPagecategory->setId(1);
$entityPagecategory->setName('URL');
$this->em->persist($entityPagecategory);
}
$entityPagecategory = $this->em->getRepository('App\Entity\Pagecategory')->find(2);
if (!$entityPagecategory) {
$entityPagecategory = new Pagecategory();
$entityPagecategory->setId(2);
$entityPagecategory->setName('Widget');
$this->em->persist($entityPagecategory);
}
$entityPagecategory = $this->em->getRepository('App\Entity\Pagecategory')->find(3);
if (!$entityPagecategory) {
$entityPagecategory = new Pagecategory();
$entityPagecategory->setId(3);
$entityPagecategory->setName('Editeur');
$this->em->persist($entityPagecategory);
}
// == WIDGET ==============================================================================================================================================
// Widget Page web
$entityWidget = $this->em->getRepository('App\Entity\Widget')->find(-2000);
if (!$entityWidget) {
$entityWidget = new Widget();
}
$entityicon = $this->em->getRepository('App\Entity\Icon')->findoneby(['label' => 'icon/icon_ribbon.png']);
$entityWidget->setId(-2000);
$entityWidget->setRoworder(0);
$entityWidget->setIcon($entityicon);
$entityWidget->setName('Page web');
$entityWidget->setDescription("Affiche le contenu d'une page web");
$entityWidget->setRouteview('app_admin_pagewidget_view_url');
$entityWidget->setHeight('630');
$entityWidget->setAutoajust(false);
$entityWidget->setBorder(true);
$entityWidget->setOpened(true);
$entityWidget->setViewheader(true);
$entityWidget->setAccess(['admin', 'all', 'group']);
$parameter = ['fields' => [['id' => 'url', 'loc' => 'col1', 'type' => 'string', 'label' => 'URL', 'value' => '', 'mandatory' => 'true']]];
$entityWidget->setParameter($parameter);
$this->em->persist($entityWidget);
// Widget Bureau
$entityWidget = $this->em->getRepository('App\Entity\Widget')->find(-1990);
if (!$entityWidget) {
$entityWidget = new Widget();
}
$entityicon = $this->em->getRepository('App\Entity\Icon')->findoneby(['label' => 'icon/icon_computer.png']);
$entityWidget->setId(-1990);
$entityWidget->setRoworder(0);
$entityWidget->setIcon($entityicon);
$entityWidget->setName('Bureau');
$entityWidget->setDescription('Affiche vos items de bureau');
$entityWidget->setRouteview('app_admin_pagewidget_view_item');
$entityWidget->setHeight('630');
$entityWidget->setAutoajust(true);
$entityWidget->setBorder(false);
$entityWidget->setOpened(true);
$entityWidget->setViewheader(true);
$entityWidget->setAccess(['admin', 'all', 'group']);
$parameter = ['fields' => [['id' => 'modedesktop', 'loc' => 'col1', 'type' => 'desktopmode', 'label' => 'Mode Affichage', 'value' => '2', 'mandatory' => 'true'], ['id' => 'withbookmark', 'loc' => 'col1', 'type' => 'withbookmark', 'label' => 'Avec Favoris', 'value' => '0', 'mandatory' => 'true'], ['id' => 'itemcategory', 'loc' => 'col1', 'type' => 'itemcategory', 'label' => 'Catégorie Affichée', 'value' => '', 'mandatory' => 'false'], ['id' => 'search', 'loc' => 'col4', 'type' => 'boolean', 'label' => 'Zone de Recherche', 'value' => '0', 'mandatory' => 'true'], ['id' => 'menu', 'loc' => 'col4', 'type' => 'boolean', 'label' => 'Menu des Catégories', 'value' => '0', 'mandatory' => 'true'], ['id' => 'menuall', 'loc' => 'col4', 'type' => 'boolean', 'label' => 'Menu toutes les Catégories', 'value' => '1', 'mandatory' => 'true']]];
$entityWidget->setParameter($parameter);
$this->em->persist($entityWidget);
// Widget Bureau Essentiel
$entityWidget = $this->em->getRepository('App\Entity\Widget')->find(-1850);
if (!$entityWidget) {
$entityWidget = new Widget();
}
$entityicon = $this->em->getRepository('App\Entity\Icon')->findoneby(['label' => 'icon/icon_computer.png']);
$entityWidget->setId(-1850);
$entityWidget->setRoworder(0);
$entityWidget->setIcon($entityicon);
$entityWidget->setName('Bureau Essentiel');
$entityWidget->setDescription('Affiche les items de bureau essentiel');
$entityWidget->setRouteview('app_admin_pagewidget_view_itemessential');
$entityWidget->setHeight('630');
$entityWidget->setAutoajust(true);
$entityWidget->setBorder(false);
$entityWidget->setOpened(true);
$entityWidget->setViewheader(true);
$entityWidget->setAccess(['admin', 'all', 'group']);
$parameter = ['fields' => [['id' => 'modedesktop', 'loc' => 'col1', 'type' => 'desktopmode', 'label' => 'Mode Affichage', 'value' => '2', 'mandatory' => 'true']]];
$entityWidget->setParameter($parameter);
$this->em->persist($entityWidget);
// Widget Liens
$entityWidget = $this->em->getRepository('App\Entity\Widget')->find(-1960);
if (!$entityWidget) {
$entityWidget = new Widget();
}
$entityicon = $this->em->getRepository('App\Entity\Icon')->findoneby(['label' => 'icon/icon_star.png']);
$entityWidget->setId(-1960);
$entityWidget->setRoworder(0);
$entityWidget->setIcon($entityicon);
$entityWidget->setName('Liens');
$entityWidget->setDescription('Bibliothèque de Liens');
$entityWidget->setRouteview('app_admin_pagewidget_view_bookmark');
$entityWidget->setHeight('630');
$entityWidget->setAutoajust(true);
$entityWidget->setBorder(false);
$entityWidget->setOpened(true);
$entityWidget->setViewheader(true);
$entityWidget->setAccess(['admin', 'all', 'group']);
$parameter = ['fields' => [['id' => 'modedesktop', 'loc' => 'col1', 'type' => 'desktopmode', 'label' => 'Mode Affichage', 'value' => '2', 'mandatory' => 'true']]];
$entityWidget->setParameter($parameter);
$this->em->persist($entityWidget);
// Widget Lien
$entityWidget = $this->em->getRepository('App\Entity\Widget')->find(-1950);
if (!$entityWidget) {
$entityWidget = new Widget();
}
$entityicon = $this->em->getRepository('App\Entity\Icon')->findoneby(['label' => 'icon/icon_bolt.png']);
$entityWidget->setId(-1950);
$entityWidget->setRoworder(0);
$entityWidget->setIcon($entityicon);
$entityWidget->setName('Lien');
$entityWidget->setDescription("Création d'un Lien unique");
$entityWidget->setRouteview('app_admin_pagewidget_view_link');
$entityWidget->setHeight('200');
$entityWidget->setAutoajust(true);
$entityWidget->setBorder(true);
$entityWidget->setOpened(true);
$entityWidget->setViewheader(false);
$entityWidget->setAccess(['admin', 'all', 'group']);
$parameter = ['fields' => [['id' => 'url', 'loc' => 'col1', 'type' => 'string', 'label' => 'URL', 'value' => '', 'mandatory' => 'true'], ['id' => 'target', 'loc' => 'col1', 'type' => 'target', 'label' => 'Ouvrir le lien dans', 'value' => '0', 'mandatory' => 'true']]];
$entityWidget->setParameter($parameter);
$this->em->persist($entityWidget);
// Widget Annonce
$entityWidget = $this->em->getRepository('App\Entity\Widget')->find(-1980);
if (!$entityWidget) {
$entityWidget = new Widget();
}
$entityicon = $this->em->getRepository('App\Entity\Icon')->findoneby(['label' => 'icon/icon_megaphone.png']);
$entityWidget->setId(-1980);
$entityWidget->setRoworder(0);
$entityWidget->setIcon($entityicon);
$entityWidget->setName('Annonces');
$entityWidget->setDescription('Affiche vos annonces');
$entityWidget->setRouteview('app_admin_pagewidget_view_alert');
$entityWidget->setHeight('630');
$entityWidget->setAutoajust(true);
$entityWidget->setBorder(false);
$entityWidget->setOpened(true);
$entityWidget->setViewheader(false);
$entityWidget->setAccess(['admin', 'all', 'group']);
$parameter = ['fields' => [['id' => 'alertcategory', 'loc' => 'col1', 'type' => 'alertcategory', 'label' => 'Catégorie Affichée', 'value' => '', 'mandatory' => 'false']]];
$entityWidget->setParameter($parameter);
$this->em->persist($entityWidget);
// Widget Informations
$entityWidget = $this->em->getRepository('App\Entity\Widget')->find(-1860);
if (!$entityWidget) {
$entityWidget = new Widget();
}
$entityicon = $this->em->getRepository('App\Entity\Icon')->findoneby(['label' => 'icon/icon_info.png']);
$entityWidget->setId(-1860);
$entityWidget->setRoworder(0);
$entityWidget->setIcon($entityicon);
$entityWidget->setName('Informations');
$entityWidget->setDescription('Afficher les informations associées à la page');
$entityWidget->setRouteview('app_admin_pagewidget_view_info');
$entityWidget->setHeight('630');
$entityWidget->setAutoajust(true);
$entityWidget->setBorder(true);
$entityWidget->setOpened(false);
$entityWidget->setViewheader(true);
$entityWidget->setViewheader(true);
$entityWidget->setColorheaderback('#5b5b5b');
$entityWidget->setColorheaderfont('#ffffff');
$entityWidget->setColorbodyback('#5b5b5b');
$entityWidget->setColorbodyfont('#ffffff');
$entityWidget->setAccess(['admin', 'all', 'group']);
$parameter = ['fields' => []];
$entityWidget->setParameter($parameter);
$this->em->persist($entityWidget);
$this->em->flush();
// == PAGETEMPALTE =======================================================================================================================================
// Template app
$entityPage = $this->em->getRepository('App\Entity\Page')->find(-100);
if (!$entityPage) {
$entityPagecategory = $this->em->getRepository('App\Entity\Pagecategory')->find(2);
$entityGroup = $this->em->getRepository("App\Entity\Group")->find(-1);
$entityPage = new Page();
$entityPage->setId(-100);
$entityPage->setRowOrder(0);
$entityPage->setName('Applications');
$entityPage->setParentfor('app');
$entityPage->setMaxwidth(1000);
$entityPage->setPagecategory($entityPagecategory);
$entityPage->addGroup($entityGroup);
$entityPage->setTemplate('{"rows":[{"id":0,"cols":[{"id":0,"size": 12,"rows":[]}]}]}');
$this->em->persist($entityPage);
$this->em->flush();
$entityPagewidget = $this->em->getRepository('App\Entity\Pagewidget')->find(-110);
if (!$entityPagewidget) {
$entityWidget = $this->em->getRepository('App\Entity\Widget')->find(-1990);
$entityPagewidget = new Pagewidget();
$entityPagewidget->setId(-110);
$entityPagewidget->setLoc('R1C1');
$entityPagewidget->setRoworder(0);
$entityPagewidget->setName('Applications');
$entityPagewidget->setHeight($entityWidget->getHeight());
$entityPagewidget->setAutoajust($entityWidget->isAutoajust());
$entityPagewidget->setBorder($entityWidget->isBorder());
$entityPagewidget->setOpened($entityWidget->isOpened());
$entityPagewidget->setViewheader($entityWidget->isViewheader());
$entityPagewidget->setIcon($entityWidget->getIcon());
$entityPagewidget->setPage($entityPage);
$entityPagewidget->setWidget($entityWidget);
$param['fields'] = ['fields' => [['id' => 'modedesktop', 'value' => 2], ['id' => 'withbookmark', 'value' => 0], ['id' => 'itemcategory', 'value' => null], ['id' => 'menu', 'value' => 1], ['id' => 'search', 'value' => 1], ['id' => 'menuall', 'value' => 1]]];
$entityPagewidget->setParameter($param['fields']);
$this->em->persist($entityPagewidget);
$this->em->flush();
}
}
// Template Group
$entityPage = $this->em->getRepository('App\Entity\Page')->find(-110);
if (!$entityPage) {
$entityPagecategory = $this->em->getRepository('App\Entity\Pagecategory')->find(2);
$entityPage = new Page();
$entityPage->setId(-110);
$entityPage->setRowOrder(0);
$entityPage->setName('Groupe Template');
$entityPage->setParentfor('group');
$entityPage->setMaxwidth(0);
$entityPage->setPagecategory($entityPagecategory);
$entityPage->setTemplate('{"rows":[{"id":0,"cols":[{"id":0,"size": 3,"rows":[]},{"id":1,"size": 6,"rows":[{"id":0,"cols":[{"id":0,"size": 6},{"id":1,"size": 6}]}]},{"id":2,"size": 3,"rows":[]}]}]}');
$this->em->persist($entityPage);
$this->em->flush();
// Widget Nos Liens
$fields = ['fields' => [['id' => 'modedesktop', 'value' => 2]]];
$this->addWidget(-120, $entityPage, -1960, 'R1C2R1C1', 0, 'Nos Liens', true, $fields);
// Widget Nos Fichiers
/*
$fields=["fields"=>[]];
$this->addWidget(-130,$entityPage,-1920,"R1C2R1C2",0,"Nos Fichiers",true,$fields);
// Widget Info Page
$fields=["fields"=>[]];
$this->addWidget(-140,$entityPage,-1860,"R1C1",0,"Information Page",true,$fields);
// Widget Tâche
$fields=["fields"=>[]];
$this->addWidget(-145,$entityPage,-1800,"R1C1",1,"Taches du groupe",true,$fields);
// Widget Notre Blog
$fields=["fields"=>[["id"=>"nbarticle","value"=>5]]];
$this->addWidget(-150,$entityPage,-1890,"R1C2",0,"Notre Blog",false,$fields);
// Widget Notre Calendrier
$fields=["fields"=>[["id"=>"nbday","value"=>30]]];
$this->addWidget(-160,$entityPage,-1900,"R1C2R1C1",1,"Notre Calendrier",true,$fields);
// Chat
$fields=["fields"=>[]];
$this->addWidget(-170,$entityPage,-1840,"R1C3",0,"Chat",false,$fields);
*/
}
$output->writeln('');
return Command::SUCCESS;
}
// == FUNCTIONS ===========================================================================================================================================
private function insertConfig($order, $category, $id, $title, $value, $default, $type, $visible, $changeable, $required, $grouped, $help)
{
$entity = $this->em->getRepository("App\Entity\Config")->find($id);
if (!$entity) {
$entity = new Config();
$entity->setId($id);
$entity->setValue($value);
}
$entity->setDefault($default);
$entity->setCategory($category);
$entity->setOrder($order);
$entity->setTitle($title);
$entity->setType($type);
$entity->setVisible($visible);
$entity->setChangeable($changeable);
$entity->setRequired($required);
$entity->setGrouped($grouped);
$entity->setHelp($help);
$this->em->persist($entity);
$this->em->flush();
}
private function writelnred($string)
{
$this->output->writeln('<fg=red>'.$string.'</>');
$this->filesystem->appendToFile($this->rootlog.'cron.log', $string."\n");
}
private function writeln($string)
{
$this->output->writeln($string);
$this->filesystem->appendToFile($this->rootlog.'cron.log', $string."\n");
}
}