本文整理汇总了PHP中FOS\UserBundle\Model\UserManagerInterface::deleteUser方法的典型用法代码示例。如果您正苦于以下问题:PHP UserManagerInterface::deleteUser方法的具体用法?PHP UserManagerInterface::deleteUser怎么用?PHP UserManagerInterface::deleteUser使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FOS\UserBundle\Model\UserManagerInterface
的用法示例。
在下文中一共展示了UserManagerInterface::deleteUser方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: deleteObject
/**
* Removes the given user object.
*
* @param DataEvent $event
*/
public function deleteObject(DataEvent $event)
{
$object = $event->getData();
if ($object instanceof UserInterface) {
$this->userManager->deleteUser($object);
$this->eventDispatcher->dispatch(Events::POST_DELETE, $event);
$event->stopPropagation();
}
}
示例2: deteleAll
public function deteleAll()
{
$users = $this->userManager->findUsers();
foreach ($users as $user) {
$this->userManager->deleteUser($user);
}
}
示例3: onKernelView
/**
* Persists, updates or delete data return by the controller if applicable.
*
* @param GetResponseForControllerResultEvent $event
*/
public function onKernelView(GetResponseForControllerResultEvent $event)
{
$user = $event->getControllerResult();
if (!$user instanceof UserInterface) {
return;
}
switch ($event->getRequest()->getMethod()) {
case Request::METHOD_POST:
case Request::METHOD_PUT:
$this->userManager->updateUser($user, false);
break;
case Request::METHOD_DELETE:
$this->userManager->deleteUser($user);
$event->setControllerResult(null);
break;
}
}
示例4: delete
/**
* Removes the User from the database.
*
* @param \Hal\Resource $resource
*
* @throws NotFoundHttpException if no user with the given id could be found.
*
* @return void
*/
public function delete(Resource $resource)
{
$data = $resource->toArray();
$user = $this->userManager->findUserByUsername($data['username']);
if (!$user) {
$errorMessage = $this->translator->trans('error.user_not_found', array('%username%' => $data['username']));
throw new NotFoundHttpException($errorMessage);
}
$this->userManager->deleteUser($user);
}
示例5: deleteFOSUser
/**
* Deletes an user from the FOSUser system
* @param User $user
*/
public function deleteFOSUser(User $user)
{
if ($user->getProvider()->getType() !== self::BUILTIN_PROVIDER) {
return;
}
$FOSUser = $this->userManager->findUserByUsername($user->getUsername());
if ($FOSUser !== null) {
$this->userManager->deleteUser($FOSUser);
}
}
示例6: testDeleteEntity
/**
* {@inheritdoc}
*
* @dataProvider propertyAccessorProvider
*/
public function testDeleteEntity(array $data = [])
{
// Instantiate User
$user = (new User())->setUsername($data['username'])->setFullname($data['fullname'])->setEmail($data['email'])->setRoles($data['roles'])->setPassword($data['plainPassword'])->setEnabled($data['enabled']);
foreach ($data['jobs'] as $job) {
// Is added two times to ensure the adder handles duplications and will add it only one time
$user->addJob($job);
$user->addJob($job);
$this->doctrineManager->persist($job);
}
$this->doctrineManager->persist($user);
$this->doctrineManager->flush();
// Actual test
$this->userManager->deleteUser($user);
foreach ($data['jobs'] as $job) {
/* @var Job $job */
$this->assertFalse($job->getUsers()->contains($user), 'Expected $job instance to no longer have a reference to $user.');
}
}
示例7: delete
/**
* @inheritdoc
*/
public function delete(FOSUserInterface $user)
{
$this->FOSUserManager->deleteUser($user);
}
示例8: delete
/**
* Deletes the given user.
*
* @param string $username
*/
public function delete($username)
{
$user = $this->findUserByUsernameOrThrowException($username);
$this->userManager->deleteUser($user);
}
示例9: remove
public function remove($entity)
{
$this->userManager->deleteUser($entity);
}