Esempio n. 1
0
 public function createMenuItemAction($name)
 {
     if ($name != '') {
         $name = urldecode($name);
         $target = $this->get('request')->request->get('target');
         $icon = $this->get('request')->request->get('icon');
         $type = $this->get('request')->request->get('type');
         $restricted = $this->get('request')->request->get('restricted');
         $restrictedClass = $this->get('request')->request->get('restrictedClass');
         if ($restrictedClass == 'vendor\\bundle\\entity\\class' || $restrictedClass == '') {
             $restrictedClass = null;
         }
         $em = $this->getDoctrine()->getEntityManager();
         $root = $em->getRepository('LowbiAdminBundle:Menu')->findOneBy(array('title' => '__root', 'parent' => null));
         if ($root == null) {
             $root = new Menu();
         }
         $menu = new Menu();
         $menu->setTitle($name);
         $menu->setType($type);
         $menu->setTarget($target);
         $menu->setParent($root);
         $menu->setRestricted($restricted);
         $menu->setRestrictedClass($restrictedClass);
         $menu->setIcon($icon);
         $em->persist($menu);
         $em->flush();
         return new Response($menu->getId());
     } else {
         return null;
     }
 }
Esempio n. 2
0
 private function loadData()
 {
     $roleAdmin = new Role('ROLE_SUPER_ADMIN');
     $roleAdmin->setName('Super administrateur');
     $roleAdmin->setDescription('Role de super administrateur');
     $this->em->persist($roleAdmin);
     $this->em->flush();
     $roleUser = new Role('ROLE_USER');
     $roleUser->setName('Utilisateur');
     $roleUser->setDescription('Role d\'utilisateur authentifié');
     $this->em->persist($roleUser);
     $this->em->flush();
     $userAdmin = new User();
     $userAdmin->setUsername('admin');
     $userAdmin->setFirstName('admin');
     $userAdmin->setLastName('admin');
     $userAdmin->setEmail('admin@admin.com');
     $userAdmin->setPlainPassword('admin');
     $userAdmin->setEnabled(true);
     $userAdmin->addRole($roleAdmin);
     $this->em->persist($userAdmin);
     $this->em->flush();
     $userAdmin = new User();
     $userAdmin->setUsername('julien');
     $userAdmin->setFirstName('Julien');
     $userAdmin->setLastName('lembo');
     $userAdmin->setEmail('julien.lembo@lowbi.com');
     $userAdmin->setPlainPassword('admin');
     $userAdmin->setEnabled(true);
     $userAdmin->addRole($roleUser);
     $this->em->persist($userAdmin);
     $this->em->flush();
     $userAdmin = new User();
     $userAdmin->setUsername('arthur');
     $userAdmin->setFirstName('Arthur');
     $userAdmin->setLastName('Leroy');
     $userAdmin->setEmail('a.leroy@nerobi.com');
     $userAdmin->setPlainPassword('admin');
     $userAdmin->setEnabled(true);
     $userAdmin->addRole($roleUser);
     $this->em->persist($userAdmin);
     $this->em->flush();
     $userAdmin = new User();
     $userAdmin->setUsername('bernard');
     $userAdmin->setFirstName('Bernard');
     $userAdmin->setLastName('Martin');
     $userAdmin->setEmail('b.martin@google.com');
     $userAdmin->setPlainPassword('admin');
     $userAdmin->setEnabled(true);
     $userAdmin->addRole($roleUser);
     $this->em->persist($userAdmin);
     $this->em->flush();
     $userAdmin = new User();
     $userAdmin->setUsername('jane');
     $userAdmin->setFirstName('Jane');
     $userAdmin->setLastName('Birkin');
     $userAdmin->setEmail('jane.birkin@free.fr');
     $userAdmin->setPlainPassword('admin');
     $userAdmin->setEnabled(true);
     $userAdmin->addRole($roleUser);
     $this->em->persist($userAdmin);
     $this->em->flush();
     //Load menu
     $menuIndex = new Menu();
     $menuIndex->setTitle('Acceuil');
     $this->em->persist($menuIndex);
     $this->em->flush();
     $menuAdmin = new Menu();
     $menuAdmin->setTitle('Administration');
     $menuAdmin->setTarget('admin');
     $menuAdmin->setType(3);
     $menuAdmin->setParent($menuIndex);
     $menuAdmin->setIcon('ui-icon ui-icon-gear');
     $this->em->persist($menuAdmin);
     $this->em->flush();
     $menuUser = new Menu();
     $menuUser->setTitle('Mon Role');
     $menuUser->setTarget('role_user');
     $menuUser->setType(3);
     $menuUser->setParent($menuIndex);
     $menuUser->setIcon('ui-icon ui-icon-person');
     $this->em->persist($menuUser);
     $this->em->flush();
 }
Esempio n. 3
0
 public function load(ObjectManager $manager)
 {
     $this->manager = $manager;
     //Load admin user and basic permissions
     $roleAdmin = new Role('ROLE_SUPER_ADMIN');
     $roleAdmin->setRole('ROLE_SUPER_ADMIN');
     $roleAdmin->setName('Super administrateur');
     $roleAdmin->setDescription('Role de super administrateur');
     $manager->persist($roleAdmin);
     $manager->flush();
     $roleUser = new Role('ROLE_USER');
     $roleUser->setRole('ROLE_USER');
     $roleUser->setName('Utilisateur');
     $roleUser->setDescription('Role d\'utilisateur authentifié');
     $manager->persist($roleUser);
     $manager->flush();
     $userAdmin = new User();
     $userAdmin->setUsername('admin');
     $userAdmin->setFirstName('admin');
     $userAdmin->setLastName('admin');
     $userAdmin->setEmail('admin@admin.com');
     $userAdmin->setPlainPassword('admin');
     $userAdmin->setEnabled(true);
     $userAdmin->addRole($roleAdmin);
     $manager->persist($userAdmin);
     $manager->flush();
     $this->installTestUsers($roleUser);
     //Load menu
     $menuRoot = new Menu();
     $menuRoot->setTitle('__root');
     $menuRoot->setLocked(false);
     $menuRoot->setRestricted(false);
     $manager->persist($menuRoot);
     $manager->flush();
     $menuIndex = new Menu();
     $menuIndex->setTitle('Acceuil');
     $menuIndex->setLocked(true);
     $menuIndex->setRestricted(false);
     $menuIndex->setParent($menuRoot);
     $manager->persist($menuIndex);
     $manager->flush();
     $menuAdmin = new Menu();
     $menuAdmin->setTitle('Administration');
     $menuAdmin->setLocked(true);
     $menuAdmin->setRestricted(true);
     $menuAdmin->setRestrictedClass('Lowbi\\SystemBundle\\Entity\\Admin');
     $menuAdmin->setTarget('admin');
     $menuAdmin->setType(3);
     $menuAdmin->setParent($menuIndex);
     $menuAdmin->setIcon('ui-icon ui-icon-gear');
     $manager->persist($menuAdmin);
     $manager->flush();
     $menuUser = new Menu();
     $menuUser->setTitle('Mon Role');
     $menuUser->setLocked(true);
     $menuUser->setRestricted(false);
     $menuUser->setTarget('role_user');
     $menuUser->setType(3);
     $menuUser->setParent($menuIndex);
     $menuUser->setIcon('ui-icon ui-icon-person');
     $manager->persist($menuUser);
     $manager->flush();
     //Load Help
     $menuHelp = new Menu();
     $menuHelp->setTitle('Aide');
     $menuHelp->setLocked(false);
     $menuHelp->setRestricted(false);
     $menuHelp->setParent($menuRoot);
     $manager->persist($menuHelp);
     $manager->flush();
     $menuAbout = new Menu();
     $menuAbout->setTitle('A propos');
     $menuAbout->setLocked(true);
     $menuAbout->setRestricted(false);
     $menuAbout->setTarget('about');
     $menuAbout->setType(3);
     $menuAbout->setParent($menuHelp);
     $menuAbout->setIcon('ui-icon ui-icon-help');
     $manager->persist($menuAbout);
     $manager->flush();
     $menuDoc = new Menu();
     $menuDoc->setTitle('Documentation');
     $menuDoc->setLocked(true);
     $menuDoc->setRestricted(false);
     $menuDoc->setTarget('doc');
     $menuDoc->setType(3);
     $menuDoc->setParent($menuHelp);
     $menuDoc->setIcon('ui-icon ui-icon-info');
     $manager->persist($menuDoc);
     $manager->flush();
     $menuSite = new Menu();
     $menuSite->setTitle('Lowbi');
     $menuSite->setLocked(true);
     $menuSite->setRestricted(false);
     $menuSite->setTarget('www.lowbi.com');
     $menuSite->setType(2);
     $menuSite->setParent($menuHelp);
     $menuSite->setIcon('ui-icon ui-icon-info');
     $manager->persist($menuSite);
     $manager->flush();
 }