本文整理汇总了PHP中AppBundle\Entity\User::removeRole方法的典型用法代码示例。如果您正苦于以下问题:PHP User::removeRole方法的具体用法?PHP User::removeRole怎么用?PHP User::removeRole使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AppBundle\Entity\User
的用法示例。
在下文中一共展示了User::removeRole方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: should_not_be_able_to_remove_undefined_role
/**
* @test
*/
public function should_not_be_able_to_remove_undefined_role()
{
$user = new User();
$user->setRoles(['ROLE_ADMIN', 'ROLE_USER']);
$user->removeRole('ROLE_UNDEFINED');
$this->assertSame(['ROLE_USER', 'ROLE_ADMIN'], $user->getRoles());
}
示例2: userNoModeratorAction
/**
* @Route("/user_no_moderator/{id}", name="admin_user_no_moderator")
* @ParamConverter("user", options={"mapping": {"id": "id"}})
*/
public function userNoModeratorAction(Request $request, User $user)
{
$user->removeRole('ROLE_MODERATOR');
$em = $this->getDoctrine()->getEntityManager();
$em->flush();
return $this->redirectToRoute('admin_users_show');
}
示例3: testRoles
public function testRoles()
{
$user = new User();
$this->assertTrue(in_array(User::$ROLE_USER, $user->getRoles()));
$user->addRole(User::$ROLE_ADMIN);
$this->assertTrue(in_array(User::$ROLE_USER, $user->getRoles()));
$this->assertTrue(in_array(User::$ROLE_ADMIN, $user->getRoles()));
$user->removeRole(User::$ROLE_ADMIN);
$this->assertFalse(in_array(User::$ROLE_ADMIN, $user->getRoles()));
}
示例4: removeRole
/**
* {@inheritDoc}
*/
public function removeRole($role)
{
$this->__initializer__ && $this->__initializer__->__invoke($this, 'removeRole', [$role]);
return parent::removeRole($role);
}