本文整理匯總了PHP中USER::setUsername方法的典型用法代碼示例。如果您正苦於以下問題:PHP USER::setUsername方法的具體用法?PHP USER::setUsername怎麽用?PHP USER::setUsername使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類USER
的用法示例。
在下文中一共展示了USER::setUsername方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: load
/**
* {@inheritDoc}
*/
public function load(ObjectManager $manager)
{
//add a test user
$user_test = new USER();
$user_testInfo = new UserInfo();
$user_test->setUsername('test');
$encoder = $this->container->get('security.encoder_factory')->getEncoder($user_test);
$user_test->setPassword($encoder->encodePassword('test', $user_test->getSalt()));
$user_test->setEmail('test@caigou.co.nz');
$user_test->setEnabled(true);
$user_test->setRoles(array('ROLE_USER'));
$user_test->setUserInfo($user_testInfo);
$manager->persist($user_test);
//add an admin user
$user_admin = new USER();
$user_adminInfo = new UserInfo();
$user_admin->setUsername('admin');
$encoder = $this->container->get('security.encoder_factory')->getEncoder($user_admin);
$user_admin->setPassword($encoder->encodePassword('admin', $user_admin->getSalt()));
$user_admin->setEmail('admin@caigou.co.nz');
$user_admin->setEnabled(true);
$user_admin->setRoles(array('ROLE_ADMIN'));
$user_admin->setUserInfo($user_adminInfo);
$manager->persist($user_admin);
//add config
$Config1 = new Config();
$Config1->setId(1);
$Config1->setTitle("");
$Config1->setRemark("");
$Config1->setCfgvalue("1");
$manager->persist($Config1);
$Config2 = new Config();
$Config2->setId(2);
$Config2->setTitle("");
$Config2->setRemark("");
$Config2->setCfgvalue("0");
$manager->persist($Config2);
$Config3 = new Config();
$Config3->setId(3);
$Config3->setTitle("");
$Config3->setRemark("");
$Config3->setCfgvalue("0");
$manager->persist($Config3);
//update
$manager->flush();
}