Это ошибка
Argument 1 passed to Symfony\Component\Security\Core\Encoder\UserPasswordEncoder::encodePassword() must be an instance of Symfony\Component\Security\Core\User\UserInterface, instance of App\Entity\User given, called in C:\Users\willi\Desktop\Crowdin\src\Controller\CompteController.php on line 44
CompteController.php:
/**
* @Route("/inscriptions", name = "inscription")
*/
public function inscriptions(Request $request, ObjectManager $manager, UserPasswordEncoderInterface $encoder) {
$user = new User();
$form = $this->createForm(RegistrationType::class, $user);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$hash = $encoder->encodePassword($user, $user->getPassword());
$user->setPassword($hash);
$manager->persist($user);
$manager->flush();
return $this->redirectToRoute('login');
}
return $this->render('compte/inscriptions.html.twig', [
'form' => $form->createView()
]);
}
User.php:
<?php
namespace App\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
use Symfony\Component\Security\Core\User\UserInterface;
/**
* @ORM\Entity(repositoryClass = "App\Repository\UserRepository")
* @UniqueEntity(
* fields = {"email"},
* message = "L'email que vous avez indiqué est déja utilisé !"
* )
*/
class User implements UserInterface
{
я уже делаю это
вам нужно мое приложение \ entity \ User?
Вы уверены, что реализовали правильный UserInterface? Что говорит var_dump($user instanceof Symfony\Component\Security\Core\User\UserInterface)?
что сказать ложь.
Как вы это реализовали?
Используйте Symfony \ Component \ Security \ Core \ User \ UserInterface в моем объекте User.php
Это еще не все.
Продолжайте и обновите свой вопрос, указав свой код пользователя. Не нужно все это показывать. Просто класс User реализует строку UserInterface.






Похоже, вы только импортируете интерфейс в локальное пространство имен, но на самом деле не реализуете его.
namespace foo; // namespace declaration
use Bar\UserInterface; // namespace import, does not actually implement it.
class User implements UserInterface { // <- this is the important part
// now you need to implement the methods specified in the interface.
}
В качестве альтернативы, предполагая, что класс Bar\User реализует Bar\UserInterface:
class User extends Bar\User {
// now you only need to define/redefine the specific things that you want to
}
App\Entity\Userдолжен либо реализовыватьSymfony\Component\Security\Core\User\UserInterface, либо дочерний интерфейс, либо расширять класс, который это делает.