本文整理匯總了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);
}