при создании или редактировании пользователя (Entreprise и простой пользователь, которые в моем случае совершенно разные) в easy admin пароль не шифруется. Я читал некоторые решения здесь https://github.com/EasyCorp/EasyAdminBundle/issues/1261 и то же самое при переполнении стека и я не понял одну вещь, у меня здесь уже есть EntrepriseController
<?php
namespace App\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
use Symfony\Component\Security\Core\User\UserInterface;
use Symfony\Component\HttpFoundation\File\File;
use Symfony\Component\HttpFoundation\File\UploadedFile;
use Symfony\Component\Validator\Context\ExecutionContextInterface;
use Vich\UploaderBundle\Mapping\Annotation as Vich;
use Symfony\Component\Validator\Constraints as Assert;
/**
* @ORM\Entity(repositoryClass="App\Repository\EntrepriseRepository")
* @UniqueEntity(fields={"email"}, message="There is already an account with this email")
* @Vich\Uploadable()
*
*/
class Entreprise implements UserInterface
{
/**
* @ORM\Id()
* @ORM\Column(type="string", length=180, unique=true)
*/
private $email;
/**
* @ORM\Column(type="json")
*/
private $roles = ["ROLE_RECRUITER"];
/**
* @var string The hashed password
* @ORM\Column(type="string")
*/
private $password;
/**
* @ORM\Column(type="string", length=255)
*/
private $adresse;
/**
* @ORM\Column(type="integer")
*/
private $numeroTelephone;
/**
* @ORM\Column(type="string", length=255)
* @var string
* @assert\valid()
*/
private $logo;
/**
* @Vich\UploadableField(mapping="featured_files",fileNameProperty="logo")
* @Assert\File(
* maxSize = "2M",
* mimeTypes = {"image/png", "image/jpg"},
* mimeTypesMessage = "veuillez téléchargé un fichier : jpg,png taille-max:2M "
* )
*/
private $logoFile;
/**
* @ORM\Column(type="datetime")
*/
private $updatedAt;
/**
* @ORM\OneToMany(targetEntity="App\Entity\OffreEmploi", mappedBy="entreprise", orphanRemoval=true)
*/
private $offres;
public function __construct()
{
$this->offres = new ArrayCollection();
$this->updatedAt= new \DateTime();
}
public function getId(): ?int
{
return $this->id;
}
public function getEmail(): ?string
{
return $this->email;
}
public function setEmail(string $email): self
{
$this->email = $email;
return $this;
}
/**
* A visual identifier that represents this user.
*
* @see UserInterface
*/
public function getUsername(): string
{
return (string) $this->email;
}
/**
* @see UserInterface
*/
public function getRoles(): array
{
$roles = $this->roles;
// guarantee every user at least has ROLE_USER
$roles[] = 'ROLE_USER';
return array_unique($roles);
}
public function setRoles(array $roles): self
{
$this->roles = $roles;
return $this;
}
/**
* @see UserInterface
*/
public function getPassword(): string
{
return (string) $this->password;
}
public function setPassword(string $password): self
{
$this->password = $password;
return $this;
}
/**
* @see UserInterface
*/
public function getSalt()
{
// not needed when using the "bcrypt" algorithm in security.yaml
}
/**
* @see UserInterface
*/
public function eraseCredentials()
{
// If you store any temporary, sensitive data on the user, clear it here
// $this->plainPassword = null;
}
public function getAdresse(): ?string
{
return $this->adresse;
}
public function setAdresse(string $adresse): self
{
$this->adresse = $adresse;
return $this;
}
public function getNumeroTelephone(): ?int
{
return $this->numeroTelephone;
}
public function setNumeroTelephone(int $numeroTelephone): self
{
$this->numeroTelephone = $numeroTelephone;
return $this;
}
public function getLogo(): ?string
{
return $this->logo;
}
public function setLogo(?string $logo): self
{
$this->logo = $logo;
return $this;
}
/**
* @return mixed
*/
public function getLogoFile()
{
return $this->logoFile;
}
/**
* @param mixed $logoFile
* @throws \Exception
*/
public function setLogoFile($logoFile): void
{
$this->logoFile = $logoFile;
if($logoFile){
$this->updatedAt=new \DateTime();
}
}
public function getUpdatedAt(): ?\DateTimeInterface
{
return $this->updatedAt;
}
/**
* @param \DateTimeInterface $updatedAt
* @return Entreprise
*/
public function setUpdatedAt(\DateTimeInterface $updatedAt): self
{
$this->updatedAt = $updatedAt;
}
/**
* @return Collection|OffreEmploi[]
*/
public function getOffres(): Collection
{
return $this->offres;
}
/**
* @param ArrayCollection $offres
*/
public function setOffres(ArrayCollection $offres): void
{
$this->offres = $offres;
}
public function addOffre(OffreEmploi $offre): self
{
if (!$this->offres->contains($offre)) {
$this->offres[] = $offre;
$offre->setEntreprise($this);
}
return $this;
}
public function removeOffre(OffreEmploi $offre): self
{
if ($this->offres->contains($offre)) {
$this->offres->removeElement($offre);
// set the owning side to null (unless already changed)
if ($offre->getEntreprise() === $this) {
$offre->setEntreprise(null);
}
}
return $this;
}
public function __toString()
{
return $this->getEmail();
}
}
Могу ли я создать другой контроллер EntrepriseController, который будет расширять EasyAdminController вместо abstractController? и как я этого не понял. Я не использую для UserBundle