コード例 #1
0
 /**
  * @Route("/managers/add", name="managers_add")
  * @Method({"GET","POST"})
  */
 public function newAction(Request $request)
 {
     $role = new Role();
     $gen = new Gen();
     $newManager = new Manager();
     $em = $this->getDoctrine()->getManager();
     $data = $request->request->get('appbundle_manager');
     $username = $gen->genUsername($data['surname'], $data['name'], $data['patronymic']);
     $users = $em->getRepository('AppBundle:User');
     while ($users->findByUsername($username)) {
         if (!isset($pers_numb)) {
             $pers_numb = 1;
             $susername = $username;
         }
         $username = $susername . $pers_numb;
         $pers_numb++;
     }
     $newManager->setRole($role->getId('MANAGER'));
     $newManager->setUsername($username);
     $newManager->setPassword($gen->genPassword());
     $form = $this->createCreateForm($newManager);
     $form->handleRequest($request);
     if ($form->isValid()) {
         $em->persist($newManager);
         $em->flush();
         return $this->redirect($this->generateUrl('managers'));
     }
     return $this->render('manager/new.html.twig', array('entity' => $newManager, 'form' => $form->createView()));
 }
コード例 #2
0
ファイル: LoadRoleData.php プロジェクト: Zenidal/Diploma
 /**
  * Load data fixtures with the passed EntityManager
  *
  * @param ObjectManager $manager
  */
 public function load(ObjectManager $manager)
 {
     foreach ($this->roles as $role) {
         $newRole = new Role();
         $newRole->setName($role['name']);
         $manager->persist($newRole);
     }
     $manager->flush();
 }
コード例 #3
0
 protected function getRole()
 {
     $em = $this->getDoctrine()->getManager();
     $role = $em->getRepository("AppBundle:Role")->findOneByName('ROLE_USER');
     if (count($role) == 0) {
         $role = new Role();
         $role->setName('ROLE_USER');
         $em->persist($role);
         $em->flush();
     }
     return $role;
 }
コード例 #4
0
 /**
  * {@inheritDoc}
  */
 public function load(ObjectManager $manager)
 {
     $superAdmin = new Role();
     $superAdmin->setName('ROLE_SUPER_ADMIN');
     $admin = new Role();
     $admin->setName('ROLE_ADMIN');
     $editor = new Role();
     $editor->setName('ROLE_EDITOR');
     $manager->persist($superAdmin);
     $manager->persist($admin);
     $manager->persist($editor);
     $manager->flush();
     $this->addReference('role-super-admin', $superAdmin);
 }
コード例 #5
0
ファイル: RoleModel.php プロジェクト: Gardax/studentsSystem
 public function __construct(Role $role)
 {
     $this->setId($role->getId());
     $name = 'User';
     switch ($role->getRole()) {
         case UserService::ROLE_TEACHER:
             $name = 'Преподавател';
             break;
         case UserService::ROLE_ADMIN:
             $name = 'Администратор';
             break;
     }
     $this->setRoleName($name);
 }
コード例 #6
0
ファイル: LoadFixtures.php プロジェクト: BookWorld1/courses
 protected function _loadRole(ObjectManager $manager)
 {
     $array = array();
     $array[] = array('role' => 'ROLE_ADMIN', 'name' => 'Admin', 'use' => false);
     $array[] = array('role' => 'ROLE_STUDENT', 'name' => 'Student', 'use' => true);
     $array[] = array('role' => 'ROLE_UNCONFIRMED_TEACHER', 'name' => 'Teacher', 'use' => true);
     $array[] = array('role' => 'ROLE_TEACHER', 'name' => 'Teacher', 'use' => false);
     foreach ($array as $roles) {
         $role = new Role();
         $role->setName($roles['name']);
         $role->setRole($roles['role']);
         $role->setUserole($roles['use']);
         $manager->persist($role);
     }
     $manager->flush();
 }
コード例 #7
0
 public function load(ObjectManager $manager)
 {
     $role = new Role();
     $role->setName('ROLE_ADMIN');
     $manager->persist($role);
     /***
      * 
      * Newsletter roles
      * 
      */
     $roles_string_list = array('ROLE_MANAGE_NEWSLETTER', 'ROLE_NEWSLETTER_ADD_CONTENT', 'ROLE_NEWSLETTER_EDIT_CONTENT', 'ROLE_NEWSLETTER_ADD_USER', 'ROLE_NEWSLETTER_EDIT_USER', 'ROLE_NEWSLETTER_SEARCH_USER', 'ROLE_NEWSLETTER_DOWNLOAD_USERS', 'ROLE_NEWSLETTER_UPLOAD_USERS', 'ROLE_NEWSLETTER_ADD_GROUP', 'ROLE_NEWSLETTER_EDIT_GROUP', 'ROLE_NEWSLETTER_REMOVE_GROUP', 'ROLE_NEWSLETTER_CREATE_EMAIL_LAYOUT', 'ROLE_NEWSLETTER_EDIT_EMAIL_LAYOUT');
     $roles_list = array();
     foreach ($roles_string_list as $name) {
         $r1 = new Role();
         $r1->setName($name);
         $manager->persist($r1);
         $roles_list[] = $r1;
     }
     $userManager = $this->container->get('fos_user.user_manager');
     $user = $userManager->createUser();
     $user->setUsername('*****@*****.**');
     $user->setEmail('*****@*****.**');
     $user->setPlainPassword('1234');
     $user->setEnabled(true);
     $user->setSuperAdmin(true);
     $user->setNombre('Rodrigo Santellan');
     $user->addRole($role);
     foreach ($roles_list as $rl) {
         $user->addRole($rl);
     }
     $manager->persist($user);
     $admin = $userManager->createUser();
     $admin->setUsername('bunnysadministrador');
     $admin->setEmail('*****@*****.**');
     $admin->setPlainPassword('bunnyskinder1974');
     $admin->setEnabled(true);
     $admin->setSuperAdmin(true);
     $admin->addRole($role);
     foreach ($roles_list as $rl) {
         $admin->addRole($rl);
     }
     $manager->persist($admin);
     $manager->flush();
 }
コード例 #8
0
ファイル: TwitterController.php プロジェクト: vinillo/example
 /**
  * @Route("/verifyLogin")
  * @Route("/verifyLogin/")
  */
 public function verifyLoginAction($getUsername, $getPassword)
 {
     $account = new account();
     $em = $this->getDoctrine()->getManager();
     $query = $em->createQueryBuilder()->select('COUNT(f.id)')->from('AppBundle:Account', 'f')->where('f.username = :username', 'f.password = :password')->setParameter('username', $getUsername)->setParameter('password', strtoupper(sha1($getUsername . ":" . $getPassword)))->getQuery();
     $total = $query->getSingleScalarResult();
     if ($total >= 1) {
         //logged in
         $role = new Role();
         $role->setName(strtoupper($getUsername));
         $role->setRole('ROLE_USER');
         return $this->redirect('/account');
     } else {
         //wrong password/username
         //die("wrong username/password");
         return $this->redirect('/login/wrong-credentials');
     }
     return $this->render('twitter/success_created.html.twig', array('getUsername' => $getUsername, 'getEmail' => $getEmail, 'current_year' => date("Y")));
 }
コード例 #9
0
ファイル: LoadRoleData.php プロジェクト: vegardbb/webpage
 public function load(ObjectManager $manager)
 {
     $role1 = new Role();
     $role1->setName('Admin');
     $role1->setRole('ROLE_ADMIN');
     $manager->persist($role1);
     $role2 = new Role();
     $role2->setName('Superadmin');
     $role2->setRole('ROLE_SUPER_ADMIN');
     $manager->persist($role2);
     $role3 = new Role();
     $role3->setName('User');
     $role3->setRole('ROLE_USER');
     $manager->persist($role3);
     $role4 = new Role();
     $role4->setName('Highest admin');
     $role4->setRole('ROLE_HIGHEST_ADMIN');
     $manager->persist($role4);
     $manager->flush();
     $this->addReference('role-1', $role1);
     $this->addReference('role-2', $role2);
     $this->addReference('role-3', $role3);
     $this->addReference('role-4', $role4);
 }
コード例 #10
0
 /**
  * {@inheritDoc}
  */
 public function load(ObjectManager $manager)
 {
     $userRole = new Role();
     $userRole->setName('User');
     $userRole->setRole('ROLE_USER');
     $userRole->setIsAllowedToSwitch(false);
     $manager->persist($userRole);
     $leadRole = new Role();
     $leadRole->setName('Lead');
     $leadRole->setRole('ROLE_LEAD');
     $leadRole->setIsAllowedToSwitch(false);
     $leadRole->addRoleToHierarchy($userRole);
     $manager->persist($leadRole);
     $adminRole = new Role();
     $adminRole->setName('Admin');
     $adminRole->setRole('ROLE_ADMIN');
     $adminRole->setIsAllowedToSwitch(false);
     $adminRole->addRoleToHierarchy($leadRole);
     $manager->persist($adminRole);
     $devRole = new Role();
     $devRole->setName('Dev');
     $devRole->setRole('ROLE_DEV');
     $devRole->setIsAllowedToSwitch(true);
     $devRole->addRoleToHierarchy($adminRole);
     $manager->persist($devRole);
     $manager->flush();
     $this->addReference('ROLE_USER', $userRole);
     $this->addReference('ROLE_LEAD', $leadRole);
     $this->addReference('ROLE_ADMIN', $adminRole);
     $this->addReference('ROLE_DEV', $devRole);
     $aclProvider = $this->container->get('security.acl.provider');
     $devRoleSecurityIdentity = new RoleSecurityIdentity('ROLE_DEV');
     $adminRoleSecurityIdentity = new RoleSecurityIdentity('ROLE_ADMIN');
     $leadRoleSecurityIdentity = new RoleSecurityIdentity('ROLE_LEAD');
     $userRoleSecurityIdentity = new RoleSecurityIdentity('ROLE_USER');
     $objectIdentity = ObjectIdentity::fromDomainObject($userRole);
     $acl = $aclProvider->createAcl($objectIdentity);
     $acl->insertObjectAce($userRoleSecurityIdentity, MaskBuilder::MASK_VIEW);
     $acl->insertObjectAce($devRoleSecurityIdentity, MaskBuilder::MASK_OPERATOR);
     $aclProvider->updateAcl($acl);
     $objectIdentity = ObjectIdentity::fromDomainObject($leadRole);
     $acl = $aclProvider->createAcl($objectIdentity);
     $acl->insertObjectAce($userRoleSecurityIdentity, MaskBuilder::MASK_VIEW);
     $acl->insertObjectAce($devRoleSecurityIdentity, MaskBuilder::MASK_OPERATOR);
     $aclProvider->updateAcl($acl);
     $objectIdentity = ObjectIdentity::fromDomainObject($adminRole);
     $acl = $aclProvider->createAcl($objectIdentity);
     $acl->insertObjectAce($userRoleSecurityIdentity, MaskBuilder::MASK_VIEW);
     $acl->insertObjectAce($devRoleSecurityIdentity, MaskBuilder::MASK_OPERATOR);
     $aclProvider->updateAcl($acl);
     $objectIdentity = ObjectIdentity::fromDomainObject($devRole);
     $acl = $aclProvider->createAcl($objectIdentity);
     $acl->insertObjectAce($devRoleSecurityIdentity, MaskBuilder::MASK_OPERATOR);
     $aclProvider->updateAcl($acl);
 }
コード例 #11
0
 public function load(ObjectManager $manager)
 {
     $user = new User();
     $user->setUsername('admin');
     $user->setUserFirstName('stamat');
     $user->setUserLastName('stamativan');
     $user->setEmail('*****@*****.**');
     $user->setApiKey(null);
     $encoder = $this->container->get('security.password_encoder');
     $password = $encoder->encodePassword($user, 'faster');
     $user->setPassword($password);
     $manager->persist($user);
     $manager->flush();
     $user2 = new User();
     $user2->setUsername('suxorr');
     $user2->setUserFirstName('mario');
     $user2->setUserLastName('hristev');
     $user2->setEmail('*****@*****.**');
     $user2->setApiKey(null);
     $encoder2 = $this->container->get('security.password_encoder');
     $password2 = $encoder2->encodePassword($user2, 'azsammario123');
     $user2->setPassword($password2);
     $manager->persist($user2);
     $manager->flush();
     $user3 = new User();
     $user3->setUsername('teacher');
     $user3->setUserFirstName('Пешо');
     $user3->setUserLastName('Петкоф');
     $user3->setEmail('*****@*****.**');
     $user3->setApiKey(null);
     $encoder3 = $this->container->get('security.password_encoder');
     $password3 = $encoder3->encodePassword($user3, 'slower');
     $user3->setPassword($password3);
     $manager->persist($user3);
     $manager->flush();
     $roleAdmin = new Role();
     $roleAdmin->setRole('ROLE_ADMIN');
     $roleAdmin->addUser($user);
     $roleAdmin->addUser($user2);
     $roleAdmin->addUser($user3);
     $manager->persist($roleAdmin);
     $roleTeacher = new Role();
     $roleTeacher->setRole('ROLE_TEACHER');
     $roleTeacher->addUser($user);
     $roleTeacher->addUser($user2);
     $roleTeacher->addUser($user3);
     $manager->persist($roleTeacher);
     $roleUser = new Role();
     $roleUser->setRole('ROLE_USER');
     $roleUser->addUser($user);
     $roleUser->addUser($user2);
     $roleUser->addUser($user3);
     $manager->persist($roleUser);
     $user->addRole($roleAdmin);
     $user->addRole($roleTeacher);
     $user->addRole($roleUser);
     $user2->addRole($roleAdmin);
     $user2->addRole($roleTeacher);
     $user2->addRole($roleUser);
     $user3->addRole($roleTeacher);
     $user3->addRole($roleUser);
     $manager->flush();
 }
コード例 #12
0
 public function load(ObjectManager $manager)
 {
     // Users
     $userNew = new User();
     $userNew->setUsername('rasben');
     $userNew->setPassword('rasben2');
     $userNew->setFullName('Benjamin Rasmussen');
     $userNew->setApiKey('apirasben');
     $manager->persist($userNew);
     $manager->flush();
     $userNew = new User();
     $userNew->setUsername('elvis');
     $userNew->setPassword('elvis2');
     $userNew->setFullName('Elvis Presley');
     $userNew->setApiKey('apielvis');
     $manager->persist($userNew);
     $manager->flush();
     $userNew = new User();
     $userNew->setUsername('sherlock');
     $userNew->setPassword('sherlock2');
     $userNew->setFullName('Sherlock Holmes');
     $userNew->setApiKey('apisherlock');
     $manager->persist($userNew);
     $manager->flush();
     $userNew = new User();
     $userNew->setUsername('alexander');
     $userNew->setPassword('alexander2');
     $userNew->setFullName('Alexander The Great');
     $userNew->setApiKey('apialexander');
     $manager->persist($userNew);
     $manager->flush();
     // Kitchens
     $kitchenNew = new Kitchen();
     $kitchenNew->setName('The Copenhagen Kitchen');
     $kitchenNew->setLocation('Copenhagen, DK');
     $manager->persist($kitchenNew);
     $manager->flush();
     $kitchenNew = new Kitchen();
     $kitchenNew->setName('The London Kitchen');
     $kitchenNew->setLocation('London, UK');
     $manager->persist($kitchenNew);
     $manager->flush();
     $kitchenNew = new Kitchen();
     $kitchenNew->setName('The Berlin Kitchen');
     $kitchenNew->setLocation('Berlin, DE');
     $manager->persist($kitchenNew);
     $manager->flush();
     // Languages
     $languageNew = new Language();
     $languageNew->setCode('en');
     $manager->persist($languageNew);
     $manager->flush();
     $languageNew = new Language();
     $languageNew->setCode('da');
     $manager->persist($languageNew);
     $manager->flush();
     $languageNew = new Language();
     $languageNew->setCode('fr');
     $manager->persist($languageNew);
     $manager->flush();
     // User Settings
     $userSettingNew = new UserSetting();
     $userSettingNew->setUserID($manager->getReference('AppBundle:User', 1));
     $userSettingNew->setDefaultKitchenID($manager->getReference('AppBundle:Kitchen', 1));
     $userSettingNew->setAutoOpenDefaultKitchen(2);
     $userSettingNew->setModerator(2);
     $userSettingNew->setLanguageCode($manager->getReference('AppBundle:Language', 'en'));
     $manager->persist($userSettingNew);
     $manager->flush();
     $userSettingNew = new UserSetting();
     $userSettingNew->setUserID($manager->getReference('AppBundle:User', 2));
     $userSettingNew->setDefaultKitchenID($manager->getReference('AppBundle:Kitchen', 2));
     $userSettingNew->setAutoOpenDefaultKitchen(1);
     $userSettingNew->setModerator(1);
     $userSettingNew->setLanguageCode($manager->getReference('AppBundle:Language', 'en'));
     $manager->persist($userSettingNew);
     $manager->flush();
     $userSettingNew = new UserSetting();
     $userSettingNew->setUserID($manager->getReference('AppBundle:User', 3));
     $userSettingNew->setDefaultKitchenID($manager->getReference('AppBundle:Kitchen', 2));
     $userSettingNew->setAutoOpenDefaultKitchen(2);
     $userSettingNew->setModerator(1);
     $userSettingNew->setLanguageCode($manager->getReference('AppBundle:Language', 'en'));
     $manager->persist($userSettingNew);
     $manager->flush();
     $userSettingNew = new UserSetting();
     $userSettingNew->setUserID($manager->getReference('AppBundle:User', 4));
     $userSettingNew->setDefaultKitchenID($manager->getReference('AppBundle:Kitchen', 2));
     $userSettingNew->setAutoOpenDefaultKitchen(4);
     $userSettingNew->setModerator(2);
     $userSettingNew->setLanguageCode($manager->getReference('AppBundle:Language', 'en'));
     $manager->persist($userSettingNew);
     $manager->flush();
     // Roles
     $roleNew = new Role();
     $roleNew->setTitle('owner');
     $manager->persist($roleNew);
     $manager->flush();
     $roleNew = new Role();
     $roleNew->setTitle('editor');
     $manager->persist($roleNew);
     $manager->flush();
     $roleNew = new Role();
     $roleNew->setTitle('reader');
     $manager->persist($roleNew);
     $manager->flush();
     // Categories
     $categoryNew = new Category();
     $categoryNew->setName('vegtables');
     $manager->persist($categoryNew);
     $manager->flush();
     $categoryNew = new Category();
     $categoryNew->setName('meats');
     $manager->persist($categoryNew);
     $manager->flush();
     $categoryNew = new Category();
     $categoryNew->setName('spices');
     $manager->persist($categoryNew);
     $manager->flush();
     $categoryNew = new Category();
     $categoryNew->setName('poultry');
     $manager->persist($categoryNew);
     $manager->flush();
     $categoryNew = new Category();
     $categoryNew->setName('bakery');
     $manager->persist($categoryNew);
     $manager->flush();
     // Kitchen Users
     $kitchenUserNew = new kitchenUser();
     $kitchenUserNew->setUserID($manager->getReference('AppBundle:User', 1));
     $kitchenUserNew->setRoleID($manager->getReference('AppBundle:Role', 1));
     $kitchenUserNew->setKitchenID($manager->getReference('AppBundle:Kitchen', 1));
     $manager->persist($kitchenUserNew);
     $manager->flush();
     $kitchenUserNew = new kitchenUser();
     $kitchenUserNew->setUserID($manager->getReference('AppBundle:User', 1));
     $kitchenUserNew->setRoleID($manager->getReference('AppBundle:Role', 2));
     $kitchenUserNew->setKitchenID($manager->getReference('AppBundle:Kitchen', 2));
     $manager->persist($kitchenUserNew);
     $manager->flush();
     $kitchenUserNew = new kitchenUser();
     $kitchenUserNew->setUserID($manager->getReference('AppBundle:User', 2));
     $kitchenUserNew->setRoleID($manager->getReference('AppBundle:Role', 1));
     $kitchenUserNew->setKitchenID($manager->getReference('AppBundle:Kitchen', 2));
     $manager->persist($kitchenUserNew);
     $manager->flush();
     $kitchenUserNew = new kitchenUser();
     $kitchenUserNew->setUserID($manager->getReference('AppBundle:User', 3));
     $kitchenUserNew->setRoleID($manager->getReference('AppBundle:Role', 2));
     $kitchenUserNew->setKitchenID($manager->getReference('AppBundle:Kitchen', 2));
     $manager->persist($kitchenUserNew);
     $manager->flush();
     // Amounts
     $amountNew = new Amount();
     $amountNew->setName('Kilogram');
     $amountNew->setShortName('kg');
     $manager->persist($amountNew);
     $manager->flush();
     $amountNew = new Amount();
     $amountNew->setName('Gram');
     $amountNew->setShortName('g');
     $manager->persist($amountNew);
     $manager->flush();
     $amountNew = new Amount();
     $amountNew->setName('Liter');
     $amountNew->setShortName('l');
     $manager->persist($amountNew);
     $manager->flush();
     $amountNew = new Amount();
     $amountNew->setName('Mililiter');
     $amountNew->setShortName('ml');
     $manager->persist($amountNew);
     $manager->flush();
     $amountNew = new Amount();
     $amountNew->setName('Teaspoon');
     $amountNew->setShortName('ts');
     $manager->persist($amountNew);
     $manager->flush();
     $amountNew = new Amount();
     $amountNew->setName('Table spoon');
     $amountNew->setShortName('tbls');
     $manager->persist($amountNew);
     $manager->flush();
     // Ingredients & names
     $ingredientNew = new Ingredient();
     $ingredientNew->setGlobal(2);
     $ingredientNew->setCategoryID($manager->getReference('AppBundle:Category', 4));
     $ingredientNew->setAmountID($manager->getReference('AppBundle:Amount', 2));
     $manager->persist($ingredientNew);
     $manager->flush();
     $ingredientNew = new IngredientName();
     $ingredientNew->setName('Toast');
     $ingredientNew->setIngredientID($manager->getReference('AppBundle:Ingredient', 1));
     $ingredientNew->setMaster(1);
     $ingredientNew->setLanguageCode($manager->getReference('AppBundle:Language', 'en'));
     $manager->persist($ingredientNew);
     $manager->flush();
     $ingredientNew = new Ingredient();
     $ingredientNew->setGlobal(2);
     $ingredientNew->setCategoryID($manager->getReference('AppBundle:Category', 2));
     $ingredientNew->setAmountID($manager->getReference('AppBundle:Amount', 2));
     $manager->persist($ingredientNew);
     $manager->flush();
     $ingredientNew = new IngredientName();
     $ingredientNew->setName('Veal');
     $ingredientNew->setIngredientID($manager->getReference('AppBundle:Ingredient', 2));
     $ingredientNew->setMaster(0);
     $ingredientNew->setLanguageCode($manager->getReference('AppBundle:Language', 'en'));
     $manager->persist($ingredientNew);
     $manager->flush();
     $ingredientNew = new Ingredient();
     $ingredientNew->setGlobal(2);
     $ingredientNew->setCategoryID($manager->getReference('AppBundle:Category', 3));
     $ingredientNew->setAmountID($manager->getReference('AppBundle:Amount', 2));
     $manager->persist($ingredientNew);
     $manager->flush();
     $ingredientNew = new IngredientName();
     $ingredientNew->setName('Chicken Wings');
     $ingredientNew->setIngredientID($manager->getReference('AppBundle:Ingredient', 3));
     $ingredientNew->setMaster(1);
     $ingredientNew->setLanguageCode($manager->getReference('AppBundle:Language', 'en'));
     $manager->persist($ingredientNew);
     $manager->flush();
 }
コード例 #13
0
ファイル: User.php プロジェクト: pafik13/doc-merch
 public function getRoles()
 {
     $role = new Role();
     return array($role->getKey($this->role));
 }
コード例 #14
0
ファイル: LoadUserData.php プロジェクト: pafik13/doc-merch
 public function load(ObjectManager $manager)
 {
     $role = new Role();
     $userAdmin = new User();
     $userAdmin->setUsername('admin');
     $userAdmin->setPassword('password');
     $userAdmin->setEmail('*****@*****.**');
     $userAdmin->setRole($role->getId('ADMIN'));
     $territory1 = new Territory();
     $territory1->setName("Округ1");
     $territory1->setKey("Описание");
     $territory2 = new Territory();
     $territory2->setName("Округ2");
     $territory2->setKey("Описание");
     $manager->persist($territory1);
     $manager->persist($territory2);
     $manager->persist($userAdmin);
     $userUser = new User();
     $userUser->setUsername('user');
     $userUser->setPassword('password');
     $userUser->setEmail('*****@*****.**');
     $userUser->setRole($role->getId('USER'));
     $manager->persist($userUser);
     $manager->flush();
     $userManager1 = new Manager();
     $userManager1->setUsername('manager1');
     $userManager1->setPassword('password');
     $userManager1->setEmail('*****@*****.**');
     $userManager1->setRole($role->getId('MANAGER'));
     $userManager1->setSurname('manager1');
     $userManager1->setName('manager1');
     $userManager1->setPatronymic('manager1');
     $userManager1->setGender('m');
     $userManager1->setBirthday(new \DateTime('1980-01-01'));
     $userManager2 = new Manager();
     $userManager2->setUsername('manager2');
     $userManager2->setPassword('password');
     $userManager2->setEmail('*****@*****.**');
     $userManager2->setRole($role->getId('MANAGER'));
     $userManager2->setSurname('manager2');
     $userManager2->setName('manager2');
     $userManager2->setPatronymic('manager2');
     $userManager2->setGender('m');
     $userManager2->setBirthday(new \DateTime('1980-01-01'));
     $manager->persist($userManager1);
     $manager->persist($userManager2);
     $userPresenter1 = new Presenter();
     $userPresenter1->setUsername('presenter1');
     $userPresenter1->setPassword('password1');
     $userPresenter1->setEmail('*****@*****.**');
     $userPresenter1->setRole($role->getId('PRESENTER'));
     $userPresenter1->setSurname('Иванов');
     $userPresenter1->setName('Иван');
     $userPresenter1->setPatronymic('Иванович');
     $userPresenter1->setGender('m');
     $userPresenter1->setBirthday(new \DateTime('1980-01-01'));
     $userPresenter1->setTerritory($territory1);
     $userPresenter1->setManager($userManager1);
     $userPresenter2 = new Presenter();
     $userPresenter2->setUsername('presenter2');
     $userPresenter2->setPassword('password2');
     $userPresenter2->setEmail('*****@*****.**');
     $userPresenter2->setRole($role->getId('PRESENTER'));
     $userPresenter2->setSurname('Петров');
     $userPresenter2->setName('Петр');
     $userPresenter2->setPatronymic('Петрович');
     $userPresenter2->setGender('m');
     $userPresenter2->setBirthday(new \DateTime('1980-01-01'));
     $userPresenter2->setManager($userManager2);
     $userPresenter2->setTerritory($territory2);
     $manager->persist($userPresenter1);
     $manager->persist($userPresenter2);
     $manager->flush();
 }
コード例 #15
0
ファイル: LoadRoleData.php プロジェクト: AB2G/abgg-symfony
 /**
  * {@inheritDoc}
  */
 public function load(ObjectManager $manager)
 {
     $role = new Role();
     $role->setName('Top Lane');
     $role->setSystName('lol_top');
     $role->setGame($this->getReference('lol-game'));
     $manager->persist($role);
     $role1 = new Role();
     $role1->setName('Middle Lane');
     $role1->setSystName('lol_mid');
     $role1->setGame($this->getReference('lol-game'));
     $manager->persist($role1);
     $role2 = new Role();
     $role2->setName('Bottom Carry');
     $role2->setSystName('lol_bot');
     $role2->setGame($this->getReference('lol-game'));
     $manager->persist($role2);
     $role3 = new Role();
     $role3->setName('Support');
     $role3->setSystName('lol_sup');
     $role3->setGame($this->getReference('lol-game'));
     $manager->persist($role3);
     $role4 = new Role();
     $role4->setName('Jungle');
     $role4->setSystName('lol_jun');
     $role4->setGame($this->getReference('lol-game'));
     $manager->persist($role4);
     $role5 = new Role();
     $role5->setName('Entry Fragger');
     $role5->setSystName('csg_ent');
     $role5->setGame($this->getReference('csgo-game'));
     $manager->persist($role5);
     $role6 = new Role();
     $role6->setName('Playmaker');
     $role6->setSystName('csg_pla');
     $role6->setGame($this->getReference('csgo-game'));
     $manager->persist($role6);
     $role7 = new Role();
     $role7->setName('Strat Caller');
     $role7->setSystName('csg_str');
     $role7->setGame($this->getReference('csgo-game'));
     $manager->persist($role7);
     $role8 = new Role();
     $role8->setName('Support');
     $role8->setSystName('csg_sup');
     $role8->setGame($this->getReference('csgo-game'));
     $manager->persist($role8);
     $role10 = new Role();
     $role10->setName('Awper');
     $role10->setSystName('csg_awp');
     $role10->setGame($this->getReference('csgo-game'));
     $manager->persist($role10);
     $role11 = new Role();
     $role11->setName('Lurker');
     $role11->setSystName('csg_lur');
     $role11->setGame($this->getReference('csgo-game'));
     $manager->persist($role11);
     $manager->flush();
     $this->addReference('role', $role);
     $this->addReference('role1', $role1);
     $this->addReference('role2', $role2);
     $this->addReference('role3', $role3);
     $this->addReference('role4', $role4);
     $this->addReference('role5', $role5);
     $this->addReference('role6', $role6);
     $this->addReference('role7', $role7);
     $this->addReference('role8', $role8);
     $this->addReference('role10', $role10);
     $this->addReference('role11', $role11);
 }
コード例 #16
0
 public function testCreateRole()
 {
     $role = Role::CreateRole('Admin', 'ADMIN');
     $this->assertInstanceOf('AppBundle\\Entity\\Role', $role);
     $this->assertEquals('Admin', $role->getName());
 }
コード例 #17
0
ファイル: LoadUserData.php プロジェクト: busaev/s3
 public function load(ObjectManager $manager)
 {
     $doctrine = $this->container->get('doctrine');
     $entities = $this->container->get('app.entities');
     /**
      *  Справочник для статусов записи
      */
     $scroll = new Scroll();
     $scroll->setCode('entry_status');
     $scroll->setTitle('Entry status');
     $scroll->setPosition('1');
     $manager->persist($scroll);
     $manager->flush();
     /**
      *  Cтатусы записи
      */
     // enabled
     $scrollItemEnable = new ScrollItem();
     $scrollItemEnable->setScroll($scroll);
     $scrollItemEnable->setCode('enable');
     $scrollItemEnable->setTitle('Enabled');
     $scrollItemEnable->setPosition(1);
     $manager->persist($scrollItemEnable);
     // disable
     $scrollItemDisable = new ScrollItem();
     $scrollItemDisable->setScroll($scroll);
     $scrollItemDisable->setCode('disable');
     $scrollItemDisable->setTitle('Disabled');
     $scrollItemDisable->setPosition(2);
     $manager->persist($scrollItemDisable);
     // delete
     $scrollItemDeleted = new ScrollItem();
     $scrollItemDeleted->setScroll($scroll);
     $scrollItemDeleted->setCode('delete');
     $scrollItemDeleted->setTitle('Deleted');
     $scrollItemDeleted->setPosition(3);
     $manager->persist($scrollItemDeleted);
     $manager->flush();
     /**
      *  Справочник для Вариантов типа данных аттрибута
      */
     $scrollAttributeDataTypes = new Scroll();
     $scrollAttributeDataTypes->setCode('data_types');
     $scrollAttributeDataTypes->setTitle('Варианты данных');
     $scrollAttributeDataTypes->setPosition('2');
     $manager->persist($scrollAttributeDataTypes);
     $manager->flush();
     /**
      *  Типы записи
      */
     // string
     $scrollItemDataString = new ScrollItem();
     $scrollItemDataString->setScroll($scrollAttributeDataTypes);
     $scrollItemDataString->setCode('string');
     $scrollItemDataString->setTitle('Строка');
     $scrollItemDataString->setPosition(1);
     $manager->persist($scrollItemDataString);
     // numeric
     $scrollItemDataNumeric = new ScrollItem();
     $scrollItemDataNumeric->setScroll($scrollAttributeDataTypes);
     $scrollItemDataNumeric->setCode('numeric');
     $scrollItemDataNumeric->setTitle('Число');
     $scrollItemDataNumeric->setPosition(2);
     $manager->persist($scrollItemDataNumeric);
     // date
     $scrollItemDataDate = new ScrollItem();
     $scrollItemDataDate->setScroll($scrollAttributeDataTypes);
     $scrollItemDataDate->setCode('date');
     $scrollItemDataDate->setTitle('Дата');
     $scrollItemDataDate->setPosition(3);
     $manager->persist($scrollItemDataDate);
     $manager->flush();
     /**
      *  Справочник для Вариантов отображения аттрибута
      */
     $scrollAttributeViewTypes = new Scroll();
     $scrollAttributeViewTypes->setCode('view_types');
     $scrollAttributeViewTypes->setTitle('Варианты отображения');
     $scrollAttributeViewTypes->setPosition('1');
     $manager->persist($scrollAttributeViewTypes);
     $manager->flush();
     /**
      *  Cтатусы записи
      */
     // string
     $scrollItemString = new ScrollItem();
     $scrollItemString->setScroll($scrollAttributeViewTypes);
     $scrollItemString->setCode('string');
     $scrollItemString->setTitle('Строка');
     $scrollItemString->setPosition(1);
     $manager->persist($scrollItemString);
     // checkbox
     $scrollItemCheckbox = new ScrollItem();
     $scrollItemCheckbox->setScroll($scrollAttributeViewTypes);
     $scrollItemCheckbox->setCode('select');
     $scrollItemCheckbox->setTitle('Выбор');
     $scrollItemCheckbox->setPosition(2);
     $manager->persist($scrollItemCheckbox);
     // select
     $scrollItemSelectd = new ScrollItem();
     $scrollItemSelectd->setScroll($scrollAttributeViewTypes);
     $scrollItemSelectd->setCode('checkbox');
     $scrollItemSelectd->setTitle('Множественный выбор');
     $scrollItemSelectd->setPosition(3);
     $manager->persist($scrollItemSelectd);
     $manager->flush();
     /**
      *  Справочник типов экшенов
      */
     $scrollActionTypes = new Scroll();
     $scrollActionTypes->setCode('action_types');
     $scrollActionTypes->setTitle('Варианты экшенов');
     $scrollActionTypes->setPosition('4');
     $manager->persist($scrollActionTypes);
     $manager->flush();
     /**
      *  Типы экшенов
      */
     // string
     $scrollItemActionIndex = new ScrollItem();
     $scrollItemActionIndex->setScroll($scrollActionTypes);
     $scrollItemActionIndex->setCode('index');
     $scrollItemActionIndex->setTitle('Индексная страница');
     $scrollItemActionIndex->setPosition(1);
     $manager->persist($scrollItemActionIndex);
     // checkbox
     $scrollItemActionShow = new ScrollItem();
     $scrollItemActionShow->setScroll($scrollActionTypes);
     $scrollItemActionShow->setCode('show');
     $scrollItemActionShow->setTitle('Обзор');
     $scrollItemActionShow->setPosition(2);
     $manager->persist($scrollItemActionShow);
     $manager->flush();
     /**
      *  Справочник для Вариантов типа данных аттрибута
      */
     $scrollProductTypes = new Scroll();
     $scrollProductTypes->setCode('shop_product_types');
     $scrollProductTypes->setTitle('Группы товаров');
     $scrollProductTypes->setPosition('100');
     $manager->persist($scrollProductTypes);
     $manager->flush();
     /**
      *  Типы записи
      */
     // clothes
     $scrollItemClothes = new ScrollItem();
     $scrollItemClothes->setScroll($scrollProductTypes);
     $scrollItemClothes->setCode('clothes');
     $scrollItemClothes->setTitle('Одежда');
     $scrollItemClothes->setPosition(1);
     $manager->persist($scrollItemClothes);
     // toys
     $scrollItemToys = new ScrollItem();
     $scrollItemToys->setScroll($scrollProductTypes);
     $scrollItemToys->setCode('toys');
     $scrollItemToys->setTitle('Игрушки');
     $scrollItemToys->setPosition(2);
     $manager->persist($scrollItemToys);
     $manager->flush();
     /**
      *  Роли пользователя
      */
     // super admin
     $roleSuperAdmin = new Role();
     $roleSuperAdmin->setName('ROLE_SUPER_ADMIN');
     $manager->persist($roleSuperAdmin);
     // admin
     $roleAdmin = new Role();
     $roleAdmin->setName('ROLE_ADMIN');
     $manager->persist($roleAdmin);
     // manager
     $roleManager = new Role();
     $roleManager->setName('ROLE_MANAGER');
     $manager->persist($roleManager);
     // moderator
     $roleModerator = new Role();
     $roleModerator->setName('ROLE_MODERATOR');
     $manager->persist($roleModerator);
     // client
     $roleClient = new Role();
     $roleClient->setName('ROLE_CLIENT');
     $manager->persist($roleClient);
     // manager
     $roleUser = new Role();
     $roleUser->setName('ROLE_USER');
     $manager->persist($roleUser);
     $manager->flush();
     /**
      *  Пользователь
      */
     $encoder = $this->container->get('security.password_encoder');
     // wy
     $userWY = new User();
     $userWY->setPassword($encoder->encodePassword($userWY, 'q1w2e3'));
     $userWY->setUsername('wy');
     $userWY->setEntryStatus($scrollItemEnable);
     $userWY->setEmail('*****@*****.**');
     $userWY->setRealName('Web-You.Ru');
     $userWY->addUserRole($roleAdmin);
     $manager->persist($userWY);
     $manager->flush();
     /**
      *  Модуль
      */
     // News
     $moduleNews = new Module();
     $moduleNews->setEntityCode('news');
     $moduleNews->setEntryStatus($scrollItemEnable);
     $moduleNews->setRoutePath('/news');
     $moduleNews->setTitle('Новости');
     $manager->persist($moduleNews);
     // Page
     $modulePage = new Module();
     $modulePage->setEntityCode('page');
     $modulePage->setEntryStatus($scrollItemEnable);
     $modulePage->setRoutePath('/pages');
     $modulePage->setTitle('Страницы');
     $manager->persist($modulePage);
     // Brend
     $moduleBrend = new Module();
     $moduleBrend->setEntityCode('brend');
     $moduleBrend->setEntryStatus($scrollItemEnable);
     $moduleBrend->setRoutePath('/brends');
     $moduleBrend->setTitle('Бренды');
     $manager->persist($moduleBrend);
     // Index
     $moduleIndex = new Module();
     $moduleIndex->setEntityCode('index');
     $moduleIndex->setEntryStatus($scrollItemEnable);
     $moduleIndex->setRoutePath('/');
     $moduleIndex->setTitle('Главная страница');
     $manager->persist($moduleIndex);
     // Catalog
     $moduleCatalog = new Module();
     $moduleCatalog->setEntityCode('catalog');
     $moduleCatalog->setEntryStatus($scrollItemEnable);
     $moduleCatalog->setRoutePath('/catalog');
     $moduleCatalog->setTitle('Каталог');
     $manager->persist($moduleCatalog);
     // User
     $moduleUser = new Module();
     $moduleUser->setEntityCode('user');
     $moduleUser->setEntryStatus($scrollItemEnable);
     $moduleUser->setRoutePath('/user');
     $moduleUser->setTitle('Пользователи');
     $manager->persist($moduleUser);
     $manager->flush();
     /**
      *  Страницы модуля PAGE
      */
     // Page - index
     $modulePageIndex = new ModulePage();
     $modulePageIndex->setEntryStatus($scrollItemEnable);
     $modulePageIndex->setModule($modulePage);
     $modulePageIndex->setTitle('Список страниц');
     $modulePageIndex->setMetaDescription('All our page');
     $modulePageIndex->setMetaKeywords('page, all page');
     $modulePageIndex->setRoutePath('/page');
     $modulePageIndex->setAction('index');
     $manager->persist($modulePageIndex);
     // Page - route
     $modulePageRoute = new ModulePage();
     $modulePageRoute->setEntryStatus($scrollItemEnable);
     $modulePageRoute->setModule($modulePage);
     $modulePageRoute->setTitle('Обзор страницы');
     $modulePageRoute->setMetaDescription('Page viewing');
     $modulePageRoute->setMetaKeywords('page, viewing');
     $modulePageRoute->setRoutePath('/page/{slug}');
     $modulePageRoute->setAction('route');
     $manager->persist($modulePageRoute);
     $manager->flush();
     /**
      *  Страницы модуля NEWS
      */
     // News - index
     $moduleNewsIndex = new ModulePage();
     $moduleNewsIndex->setEntryStatus($scrollItemEnable);
     $moduleNewsIndex->setModule($moduleNews);
     $moduleNewsIndex->setTitle('Список новостей');
     $moduleNewsIndex->setMetaDescription('All our news');
     $moduleNewsIndex->setMetaKeywords('news, all news');
     $moduleNewsIndex->setRoutePath('/news');
     $moduleNewsIndex->setAction('route');
     $manager->persist($moduleNewsIndex);
     // News - route
     $moduleNewsRoute = new ModulePage();
     $moduleNewsRoute->setEntryStatus($scrollItemEnable);
     $moduleNewsRoute->setModule($moduleNews);
     $moduleNewsRoute->setTitle('Обзор новости');
     $moduleNewsRoute->setMetaDescription('News viewing');
     $moduleNewsRoute->setMetaKeywords('news, viewing');
     $moduleNewsRoute->setRoutePath('/news/{slug}');
     $moduleNewsRoute->setAction('route');
     $manager->persist($moduleNewsRoute);
     $manager->flush();
     /**
      *  Страницы модуля Index
      */
     // Index - index
     $moduleIndexIndex = new ModulePage();
     $moduleIndexIndex->setEntryStatus($scrollItemEnable);
     $moduleIndexIndex->setModule($moduleIndex);
     $moduleIndexIndex->setTitle('Индекс');
     $moduleIndexIndex->setMetaDescription('Index page');
     $moduleIndexIndex->setMetaKeywords('Index page');
     $moduleIndexIndex->setRoutePath('/');
     $moduleIndexIndex->setAction('route');
     $manager->persist($moduleIndexIndex);
     $manager->flush();
     /**
      *  Страницы модуля Catalog
      */
     // catalog - index
     $moduleCatalogIndex = new ModulePage();
     $moduleCatalogIndex->setEntryStatus($scrollItemEnable);
     $moduleCatalogIndex->setModule($moduleCatalog);
     $moduleCatalogIndex->setTitle('Каталог');
     $moduleCatalogIndex->setMetaDescription('Каталог товаров');
     $moduleCatalogIndex->setMetaKeywords('Каталог, товары');
     $moduleCatalogIndex->setRoutePath('/catalog');
     $moduleCatalogIndex->setAction('route');
     $manager->persist($moduleCatalogIndex);
     // catalog - route
     $moduleCatalogRoute = new ModulePage();
     $moduleCatalogRoute->setEntryStatus($scrollItemEnable);
     $moduleCatalogRoute->setModule($moduleCatalog);
     $moduleCatalogRoute->setTitle('Обзор категории');
     $moduleCatalogRoute->setMetaDescription('Обзор категории');
     $moduleCatalogRoute->setMetaKeywords('Обзор, категории');
     $moduleCatalogRoute->setRoutePath('/catalog/category/{slug}');
     $moduleCatalogRoute->setAction('route');
     $manager->persist($moduleCatalogRoute);
     $manager->flush();
     /**
      *  Страницы модуля Brend
      */
     // brends - index
     $moduleBrendsIndex = new ModulePage();
     $moduleBrendsIndex->setEntryStatus($scrollItemEnable);
     $moduleBrendsIndex->setModule($moduleBrend);
     $moduleBrendsIndex->setTitle('Бренды');
     $moduleBrendsIndex->setMetaDescription('Список брендов');
     $moduleBrendsIndex->setMetaKeywords('бренды');
     $moduleBrendsIndex->setRoutePath('/brends');
     $moduleBrendsIndex->setAction('route');
     $manager->persist($moduleBrendsIndex);
     // brends - route
     $moduleBrendsRoute = new ModulePage();
     $moduleBrendsRoute->setEntryStatus($scrollItemEnable);
     $moduleBrendsRoute->setModule($moduleBrend);
     $moduleBrendsRoute->setTitle('Обзор бренда');
     $moduleBrendsRoute->setMetaDescription('Обзор бренда');
     $moduleBrendsRoute->setMetaKeywords('Обзор, бренд');
     $moduleBrendsRoute->setRoutePath('/brend/{slug}');
     $moduleBrendsRoute->setAction('route');
     $manager->persist($moduleBrendsRoute);
     $manager->flush();
     /**
      *  Страницы модуля User
      */
     // user - auth
     $moduleBrendsLogin = new ModulePage();
     $moduleBrendsLogin->setEntryStatus($scrollItemEnable);
     $moduleBrendsLogin->setModule($moduleUser);
     $moduleBrendsLogin->setTitle('Авторизация');
     $moduleBrendsLogin->setMetaDescription('Авторизация на сайте');
     $moduleBrendsLogin->setMetaKeywords('Авторизация на сайте');
     $moduleBrendsLogin->setRoutePath('/login');
     $moduleBrendsLogin->setAction('login');
     $manager->persist($moduleBrendsLogin);
     $manager->flush();
     /**
      *  Навигация
      */
     // Top menu
     $topNavigation = new Navigation();
     $topNavigation->setEntryStatus($scrollItemEnable);
     $topNavigation->setTitle('Top menu');
     $topNavigation->setCode('top_menu');
     $manager->persist($topNavigation);
     // Top menu items
     $topNavigationItemNews = new NavigationItem();
     $topNavigationItemNews->setEntryStatus($scrollItemEnable);
     $topNavigationItemNews->setModule($moduleNews);
     $topNavigationItemNews->setNavigation($topNavigation);
     $topNavigationItemNews->setRoute($moduleNewsIndex->getRoute());
     $topNavigationItemNews->setPosition(1);
     $topNavigationItemNews->setTitle('News');
     $topNavigationItemNews->setModulePage($moduleNewsIndex);
     //$manager->persist($topNavigationItemNews);
     $manager->flush();
     /**
      *  Аттрибуты товаров
      */
     $entityScroll = $entities->scroll_item;
     $status = $doctrine->getRepository($entityScroll->getLogicalName())->findByScrollItemCodeAndScrollCode('enable', 'entry_status');
     $dataTypes = $doctrine->getRepository($entityScroll->getLogicalName())->findByScrollItemCodeAndScrollCode('numeric', 'data_types');
     $viewTypes = $doctrine->getRepository($entityScroll->getLogicalName())->findByScrollItemCodeAndScrollCode('select', 'view_types');
     $productTypes = $doctrine->getRepository($entityScroll->getLogicalName())->findByScrollItemCodeAndScrollCode('clothes', 'shop_product_types');
     $attributeSize = new Attribute();
     $attributeSize->setTitle('Размер');
     $attributeSize->setDescription('Размеры одежды');
     $attributeSize->setInFilters(true);
     $attributeSize->setInPreview(true);
     $attributeSize->setEntryStatus($status);
     $attributeSize->setDataType($dataTypes);
     $attributeSize->setViewType($viewTypes);
     $attributeSize->setProductType($productTypes);
     $manager->persist($attributeSize);
     $manager->flush();
     //авторизуемся
     $this->container->get('security.token_storage')->setToken(new UsernamePasswordToken($userWY, null, 'secured_area', $userWY->getRoles()));
     //IMPORT
     $this->loadNewsCSV($manager, $scrollItemEnable);
     $this->loadBrendsCSV($manager, $scrollItemEnable);
 }
コード例 #18
0
ファイル: Performance.php プロジェクト: 0TshELn1ck/CheTheatre
 /**
  * Add role
  *
  * @param  \AppBundle\Entity\Role $role
  * @return Performance
  */
 public function addRole(\AppBundle\Entity\Role $role)
 {
     $role->setPerformance($this);
     $this->roles[] = $role;
     return $this;
 }
コード例 #19
0
 public function testAddRole()
 {
     // new entity
     $user = new User();
     // New dummy entity
     $role1 = new Role();
     $role1->setName("role1");
     // Use the addRole method
     $user->addRole($role1);
     // Roles is stored in an array
     $roles = $user->getRoles();
     // Loop through the array and check for matches
     foreach ($roles as $role) {
         if ($role1 == $role) {
             // Assert the result
             $this->assertEquals($role1, $role);
         }
     }
 }
コード例 #20
0
 public function testRemoveUser()
 {
     // new entity
     $role = new Role();
     $user1 = new User();
     $user1->setFirstName("Per");
     $user2 = new User();
     $user2->setFirstName("Hans");
     $user3 = new User();
     $user3->setFirstName("Ole");
     // Use the addUser method
     $role->addUser($user1);
     $role->addUser($user2);
     $role->addUser($user3);
     // Remove $user1
     $role->removeUser($user1);
     // Teams are stored in an array
     $users = $role->getUsers();
     // Loop through the array
     foreach ($users as $user) {
         // Assert the result
         $this->assertNotEquals($user1, $user);
     }
 }