ninegate/src/cadolesuser-1.0/src/Cadoles/PortalBundle/Command/InitDataCommand.php

377 lines
17 KiB
PHP
Raw Normal View History

2019-03-12 14:50:57 +01:00
<?php
namespace Cadoles\PortalBundle\Command;
2019-03-13 17:30:41 +01:00
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
2019-03-12 14:50:57 +01:00
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Finder\Finder;
use Symfony\Component\HttpKernel\KernelInterface;
use Doctrine\DBAL\Connection as DBALConnection;
2019-03-21 17:15:06 +01:00
use Doctrine\ORM\em;
use Doctrine\ORM\Mapping\ClassMetadata;
use Doctrine\ORM\Id\AssignedGenerator;
2019-03-12 14:50:57 +01:00
2019-03-13 17:30:41 +01:00
use Cadoles\PortalBundle\Entity\Icon;
2019-03-21 17:15:06 +01:00
use Cadoles\PortalBundle\Entity\Pagecategory;
use Cadoles\PortalBundle\Entity\Widget;
2019-03-12 14:50:57 +01:00
2019-03-13 17:30:41 +01:00
class InitDataCommand extends ContainerAwareCommand
2019-03-12 14:50:57 +01:00
{
protected function configure()
{
$this
->setName('Portal:InitData')
->setDescription('Init Data for Portal')
->setHelp('This command Init Data for Portal')
;
}
protected function execute(InputInterface $input, OutputInterface $output)
{
2019-03-13 17:30:41 +01:00
$em = $this->getContainer()->get('doctrine')->getEntityManager();
$output->writeln('PORTAL = Default Data');
// Creation des icons
2019-03-21 17:15:06 +01:00
$output->writeln(' > Creation Icons');
2019-03-13 17:30:41 +01:00
$finder = new Finder();
$finder->in('web/uploads/icon/');
$finder->name('icon_*');
foreach ($finder as $file) {
$image="uploads/icon/".$file->getRelativePathname();
$entityicon = $em->getRepository('CadolesPortalBundle:Icon')->findoneby(["label"=>$image]);
if(!$entityicon) {
$entityicon = new Icon;
$entityicon->setLabel($image);
$em->persist($entityicon);
}
}
2019-03-21 17:15:06 +01:00
// Creation des pagecategory
$output->writeln(' > Creation Pagecategory');
$entityPagecategory = $em->getRepository('CadolesPortalBundle:Pagecategory')->find(1);
if(!$entityPagecategory) {
$entityPagecategory = new Pagecategory();
$entityPagecategory->setId(1);
$entityPagecategory->setName('URL');
$em->persist($entityPagecategory);
}
$entityPagecategory = $em->getRepository('CadolesPortalBundle:Pagecategory')->find(2);
if(!$entityPagecategory) {
$entityPagecategory = new Pagecategory();
$entityPagecategory->setId(2);
$entityPagecategory->setName('Widget');
$em->persist($entityPagecategory);
}
$entityPagecategory = $em->getRepository('CadolesPortalBundle:Pagecategory')->find(3);
if(!$entityPagecategory) {
$entityPagecategory = new Pagecategory();
$entityPagecategory->setId(3);
$entityPagecategory->setName('Editeur');
$em->persist($entityPagecategory);
}
2019-04-02 11:26:41 +02:00
// Widget URL
2019-03-21 17:15:06 +01:00
$output->writeln(' > Creation Widget');
$entityWidget = $em->getRepository('CadolesPortalBundle:Widget')->find(-2000);
if(!$entityWidget) {
$entityicon = $em->getRepository('CadolesPortalBundle:Icon')->findoneby(["label"=>"uploads/icon/icon_ribbon.png"]);
$entityWidget = new Widget();
$entityWidget->setId(-2000);
$entityWidget->setRoworder(1);
$entityWidget->setIcon($entityicon);
$entityWidget->setName('URL');
$entityWidget->setDescription("Affiche le contenu d'une url");
$entityWidget->setRouteview("cadoles_portal_config_panelwidget_view_url");
$entityWidget->setHeight("630");
$entityWidget->setAutoajust(false);
$entityWidget->setBorder(true);
$parameter = json_decode('{"fields": [{"id": "url", "loc": "col1", "type": "string", "label": "URL", "value": "", "mandatory": "true"}]}');
$entityWidget->setParameter($parameter);
$em->persist($entityWidget);
}
2019-04-02 11:26:41 +02:00
// Widget Bureau
2019-03-21 17:15:06 +01:00
$entityWidget = $em->getRepository('CadolesPortalBundle:Widget')->find(-1990);
if(!$entityWidget) {
$entityicon = $em->getRepository('CadolesPortalBundle:Icon')->findoneby(["label"=>"uploads/icon/icon_computer.png"]);
$entityWidget = new Widget();
$entityWidget->setId(-1990);
$entityWidget->setRoworder(2);
$entityWidget->setIcon($entityicon);
$entityWidget->setName('Bureau');
$entityWidget->setDescription("Affiche vos items de bureau");
$entityWidget->setRouteview("cadoles_portal_config_panelwidget_view_item");
$entityWidget->setHeight("630");
$entityWidget->setAutoajust(true);
2019-04-02 11:26:41 +02:00
$entityWidget->setBorder(true);
2019-03-21 17:15:06 +01:00
2019-04-02 11:26:41 +02:00
$parameter = json_decode('{"fields": [{"id": "modedesktop", "loc": "col1", "type": "desktopmode", "label": "Mode Affichage", "value": "0", "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"}]}');
2019-03-21 17:15:06 +01:00
$entityWidget->setParameter($parameter);
$em->persist($entityWidget);
}
2019-04-02 11:26:41 +02:00
// Widget Annonce
2019-03-21 17:15:06 +01:00
$entityWidget = $em->getRepository('CadolesPortalBundle:Widget')->find(-1980);
if(!$entityWidget) {
$entityicon = $em->getRepository('CadolesPortalBundle:Icon')->findoneby(["label"=>"uploads/icon/icon_megaphone.png"]);
$entityWidget = new Widget();
$entityWidget->setId(-1980);
$entityWidget->setRoworder(3);
$entityWidget->setIcon($entityicon);
$entityWidget->setName('Annonces');
$entityWidget->setDescription("Affiche vos annonces");
$entityWidget->setRouteview("cadoles_portal_config_panelwidget_view_alert");
$entityWidget->setHeight("630");
$entityWidget->setAutoajust(true);
2019-04-02 11:26:41 +02:00
$entityWidget->setBorder(true);
2019-03-21 17:15:06 +01:00
$parameter = json_decode('{"fields": [{"id": "alertcategory", "loc": "col1", "type": "alertcategory", "label": "Catégorie Affichée", "value": "", "mandatory": "false"}]}');
$entityWidget->setParameter($parameter);
$em->persist($entityWidget);
}
2019-04-02 11:26:41 +02:00
// Widget Flux
$entityWidget = $em->getRepository('CadolesPortalBundle:Widget')->find(-1970);
if(!$entityWidget) {
$entityicon = $em->getRepository('CadolesPortalBundle:Icon')->findoneby(["label"=>"uploads/icon/icon_rss.png"]);
$entityWidget = new Widget();
$entityWidget->setId(-1970);
$entityWidget->setRoworder(4);
$entityWidget->setIcon($entityicon);
$entityWidget->setName('Flux');
$entityWidget->setDescription("Affiche vos flux RSS");
$entityWidget->setRouteview("cadoles_portal_config_panelwidget_view_flux");
$entityWidget->setHeight("630");
$entityWidget->setAutoajust(true);
$entityWidget->setBorder(true);
$parameter = json_decode('{"fields": []}');
$entityWidget->setParameter($parameter);
$em->persist($entityWidget);
}
// Widget Favoris
$entityWidget = $em->getRepository('CadolesPortalBundle:Widget')->find(-1960);
if(!$entityWidget) {
$entityicon = $em->getRepository('CadolesPortalBundle:Icon')->findoneby(["label"=>"uploads/icon/icon_star.png"]);
$entityWidget = new Widget();
$entityWidget->setId(-1960);
$entityWidget->setRoworder(5);
$entityWidget->setIcon($entityicon);
$entityWidget->setName('Favoris');
$entityWidget->setDescription("Création de Favoris");
$entityWidget->setRouteview("cadoles_portal_config_panelwidget_view_bookmark");
$entityWidget->setHeight("630");
$entityWidget->setAutoajust(true);
$entityWidget->setBorder(true);
$parameter = json_decode('{"fields": [{"id": "modedesktop", "loc": "col1", "type": "desktopmode", "label": "Mode Affichage", "value": "0", "mandatory": "true"}]}');
$entityWidget->setParameter($parameter);
$em->persist($entityWidget);
}
// Widget Liens
$entityWidget = $em->getRepository('CadolesPortalBundle:Widget')->find(-1950);
if(!$entityWidget) {
$entityicon = $em->getRepository('CadolesPortalBundle:Icon')->findoneby(["label"=>"uploads/icon/icon_bolt.png"]);
$entityWidget = new Widget();
$entityWidget->setId(-1950);
$entityWidget->setRoworder(6);
$entityWidget->setIcon($entityicon);
$entityWidget->setName('Lien');
$entityWidget->setDescription("Création d'un Lien");
$entityWidget->setRouteview("cadoles_portal_config_panelwidget_view_link");
$entityWidget->setHeight("200");
$entityWidget->setAutoajust(true);
$entityWidget->setBorder(true);
$parameter = json_decode('{"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);
$em->persist($entityWidget);
}
2019-04-05 11:52:31 +02:00
// Widget Editor
2019-04-02 11:26:41 +02:00
$entityWidget = $em->getRepository('CadolesPortalBundle:Widget')->find(-1940);
if(!$entityWidget) {
$entityicon = $em->getRepository('CadolesPortalBundle:Icon')->findoneby(["label"=>"uploads/icon/icon_compose.png"]);
$entityWidget = new Widget();
$entityWidget->setId(-1940);
$entityWidget->setRoworder(7);
$entityWidget->setIcon($entityicon);
$entityWidget->setName('Editeur');
$entityWidget->setDescription("Votre propre texte à éditer");
$entityWidget->setRouteview("cadoles_portal_config_panelwidget_view_editor");
$entityWidget->setHeight("630");
$entityWidget->setAutoajust(true);
$entityWidget->setBorder(true);
$parameter = json_decode('{"fields": [{"id": "html", "loc": "col5", "type": "ckeditor", "label": "Texte", "value": "", "mandatory": "false"}]}');
$entityWidget->setParameter($parameter);
$em->persist($entityWidget);
}
// Widget Carrousel
$entityWidget = $em->getRepository('CadolesPortalBundle:Widget')->find(-1930);
if(!$entityWidget) {
$entityicon = $em->getRepository('CadolesPortalBundle:Icon')->findoneby(["label"=>"uploads/icon/icon_easel.png"]);
$entityWidget = new Widget();
$entityWidget->setId(-1930);
$entityWidget->setRoworder(8);
$entityWidget->setIcon($entityicon);
$entityWidget->setName('Carrousel');
$entityWidget->setDescription("Carrousel d'images");
$entityWidget->setRouteview("cadoles_portal_config_panelwidget_view_slide");
$entityWidget->setHeight("400");
$entityWidget->setAutoajust(false);
$entityWidget->setBorder(false);
$parameter = json_decode('{"fields": [{"id": "interval", "loc": "col1", "type": "integer", "label": "Interval en seconde entre 2 images", "value": "5", "mandatory": "false"}]}');
$entityWidget->setParameter($parameter);
$em->persist($entityWidget);
}
// Widget File
$entityWidget = $em->getRepository('CadolesPortalBundle:Widget')->find(-1920);
if(!$entityWidget) {
$entityicon = $em->getRepository('CadolesPortalBundle:Icon')->findoneby(["label"=>"uploads/icon/icon_folder.png"]);
$entityWidget = new Widget();
$entityWidget->setId(-1920);
$entityWidget->setRoworder(9);
$entityWidget->setIcon($entityicon);
$entityWidget->setName('Fichiers');
$entityWidget->setDescription("Répertoire de fichiers");
$entityWidget->setRouteview("cadoles_portal_config_panelwidget_view_file");
$entityWidget->setHeight("630");
$entityWidget->setAutoajust(true);
$entityWidget->setBorder(true);
$parameter = json_decode('{"fields": []}');
$entityWidget->setParameter($parameter);
$em->persist($entityWidget);
}
// Widget Galery
$entityWidget = $em->getRepository('CadolesPortalBundle:Widget')->find(-1910);
if(!$entityWidget) {
$entityicon = $em->getRepository('CadolesPortalBundle:Icon')->findoneby(["label"=>"uploads/icon/icon_image.png"]);
$entityWidget = new Widget();
$entityWidget->setId(-1910);
$entityWidget->setRoworder(10);
$entityWidget->setIcon($entityicon);
$entityWidget->setName('Galerie');
2019-04-05 11:52:31 +02:00
$entityWidget->setDescription("Galerie d'images");
2019-04-02 11:26:41 +02:00
$entityWidget->setRouteview("cadoles_portal_config_panelwidget_view_galery");
$entityWidget->setHeight("630");
$entityWidget->setAutoajust(true);
$entityWidget->setBorder(true);
$parameter = json_decode('{"fields": []}');
$entityWidget->setParameter($parameter);
$em->persist($entityWidget);
}
2019-04-05 11:52:31 +02:00
// Widget Calendrier
$entityWidget = $em->getRepository('CadolesPortalBundle:Widget')->find(-1900);
if(!$entityWidget) {
$entityicon = $em->getRepository('CadolesPortalBundle:Icon')->findoneby(["label"=>"uploads/icon/icon_calendar.png"]);
$entityWidget = new Widget();
$entityWidget->setId(-1900);
$entityWidget->setRoworder(11);
$entityWidget->setIcon($entityicon);
$entityWidget->setName('Calendrier');
$entityWidget->setDescription("Calendrier d'évènements");
$entityWidget->setRouteview("cadoles_portal_config_panelwidget_view_calendar");
$entityWidget->setHeight("630");
$entityWidget->setAutoajust(true);
$entityWidget->setBorder(true);
$parameter = json_decode('{"fields": [{"id": "nbday", "loc": "col1", "type": "integer", "label": "Nombre de jours affichés", "value": "15", "mandatory": "true"}]}');
$entityWidget->setParameter($parameter);
$em->persist($entityWidget);
}
2019-04-02 11:26:41 +02:00
// Widget Horloge
$entityWidget = $em->getRepository('CadolesPortalBundle:Widget')->find(-1500);
if(!$entityWidget) {
$entityicon = $em->getRepository('CadolesPortalBundle:Icon')->findoneby(["label"=>"uploads/icon/icon_clock.png"]);
$entityWidget = new Widget();
$entityWidget->setId(-1500);
$entityWidget->setRoworder(100);
$entityWidget->setIcon($entityicon);
$entityWidget->setName('Horloge');
2019-04-05 11:52:31 +02:00
$entityWidget->setDescription("Une simple horloge");
2019-04-02 11:26:41 +02:00
$entityWidget->setRouteview("cadoles_portal_config_panelwidget_view_clock");
$entityWidget->setHeight("300");
$entityWidget->setAutoajust(false);
$entityWidget->setBorder(true);
$parameter = json_decode('{"fields": [{"id": "clock", "loc": "col1", "type": "clock", "label": "Mode d\'affichage", "value": "0", "mandatory": "true"}]}');
$entityWidget->setParameter($parameter);
$em->persist($entityWidget);
}
// Widget Calculatrice
$entityWidget = $em->getRepository('CadolesPortalBundle:Widget')->find(-1490);
if(!$entityWidget) {
$entityicon = $em->getRepository('CadolesPortalBundle:Icon')->findoneby(["label"=>"uploads/icon/icon_calculator.png"]);
$entityWidget = new Widget();
$entityWidget->setId(-1490);
$entityWidget->setRoworder(110);
$entityWidget->setIcon($entityicon);
$entityWidget->setName('Calculatrice');
2019-04-05 11:52:31 +02:00
$entityWidget->setDescription("Une simple calculatrice");
2019-04-02 11:26:41 +02:00
$entityWidget->setRouteview("cadoles_portal_config_panelwidget_view_calculator");
$entityWidget->setHeight("400");
$entityWidget->setAutoajust(false);
$entityWidget->setBorder(true);
$parameter = json_decode('{"fields": []}');
$entityWidget->setParameter($parameter);
$em->persist($entityWidget);
}
2019-03-21 17:15:06 +01:00
// afin de forcer les ID sur certaines entités
$metadata = $em->getClassMetaData(get_class($entityWidget));
$metadata->setIdGeneratorType(ClassMetadata::GENERATOR_TYPE_NONE);
$metadata->setIdGenerator(new AssignedGenerator());
$metadata = $em->getClassMetaData(get_class($entityPagecategory));
$metadata->setIdGeneratorType(ClassMetadata::GENERATOR_TYPE_NONE);
$metadata->setIdGenerator(new AssignedGenerator());
2019-03-13 17:30:41 +01:00
$em->flush();
$output->writeln('');
2019-03-12 14:50:57 +01:00
}
}