當前位置: 首頁>>代碼示例>>PHP>>正文


PHP User::setApiKey方法代碼示例

本文整理匯總了PHP中AppBundle\Entity\User::setApiKey方法的典型用法代碼示例。如果您正苦於以下問題:PHP User::setApiKey方法的具體用法?PHP User::setApiKey怎麽用?PHP User::setApiKey使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在AppBundle\Entity\User的用法示例。


在下文中一共展示了User::setApiKey方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: load

 public function load(ObjectManager $manager)
 {
     $user = new User();
     $user->setUsername('admin');
     $user->setUserFirstName('stamat');
     $user->setUserLastName('stamativan');
     $user->setEmail('admin@test.com');
     $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('hristevmario@gmail.com');
     $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('teacher@test.com');
     $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();
 }
開發者ID:Gardax,項目名稱:studentsSystem,代碼行數:63,代碼來源:LoadUserData.php

示例2: setApiKey

 /**
  * {@inheritDoc}
  */
 public function setApiKey($apiKey)
 {
     $this->__initializer__ && $this->__initializer__->__invoke($this, 'setApiKey', array($apiKey));
     return parent::setApiKey($apiKey);
 }
開發者ID:Akwarius,項目名稱:Symfony_Guillaume_Simon,代碼行數:8,代碼來源:__CG__AppBundleEntityUser.php

示例3: load

 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');
//.........這裏部分代碼省略.........
開發者ID:rasben,項目名稱:kitchentory-backend-api,代碼行數:101,代碼來源:LoadMockData.php

示例4: apiKeyAction

 /**
  *
  * @Route("/user/{user}/apikey", name="user.apikey")
  * @Method({"POST"})
  */
 public function apiKeyAction(User $user, Request $request)
 {
     $random = bin2hex(random_bytes(30));
     $user->setApiKey($random);
     /** @var EntityManager $em */
     $em = $this->getDoctrine()->getManager();
     $em->persist($user);
     $em->flush();
     $this->addFlash('notice', 'Here is a new API key for user ' . $user->getUsername() . ' ' . $random);
     return $this->redirectToRoute('user.index');
 }
開發者ID:theus77,項目名稱:ElasticMS,代碼行數:16,代碼來源:UserController.php


注:本文中的AppBundle\Entity\User::setApiKey方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。