本文整理汇总了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();
}