Я прихожу к вам, потому что у меня есть проблема, и я не могу найти решение.
Я ищу это, я не ухожу ...
Я быхотелось бы иметь возможность редактировать «пользовательский» аккаунт для изменения его изображения (точнее, логотипа поставщика услуг).На данный момент мои «пользователи» создаются с помощью приборов, а изображение помещается в БД через сущность Image, которая содержит идентификатор пользователя.Но когда я захожу в свою учетную запись и хочу изменить свою учетную запись, у меня появляется это сообщение:
Ни свойство "imageFile", ни один из методов "getImageFile ()", "imageFile ()", "isImageFile () "," hasImageFile () "," __get () "существуют и имеют открытый доступ в классе" App \ Entity \ Provider ".
Я указываю, что работаю с пакетом VichUploader.Я добавлю немного кода, понимание, вероятно, будет проще;)
Логотип моей сущности:
<?php
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\HttpFoundation\File\File;
use Vich\UploaderBundle\Mapping\Annotation as Vich;
/**
* @ORM\Entity(repositoryClass="App\Repository\LogosRepository")
* @Vich\Uploadable
*/
class Logos
{
/**
* @ORM\Id()
* @ORM\GeneratedValue()
* @ORM\Column(type="integer")
*/
private $id;
/**
* @var string|null
* @ORM\Column(type="string", length=255)
*/
private $filename;
/**
* @var File|null
* @Vich\UploadableField(mapping="provider_logo", fileNameProperty="filename")
*/
private $imageFile;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Provider", inversedBy="logos")
*/
private $Provider;
public function getId(): ?int
{
return $this->id;
}
public function getFilename(): ?string
{
return $this->filename;
}
public function setFilename(string $filename): self
{
$this->filename = $filename;
return $this;
}
public function getProvider(): ?Provider
{
return $this->Provider;
}
public function setProvider(?Provider $Provider): self
{
$this->Provider = $Provider;
return $this;
}
/**
* @return null|File
*/
public function getImageFile()
{
return $this->imageFile;
}
/**
* @param null|File $imageFile
* @return Logos
*/
public function setImageFile($imageFile)
{
$this->imageFile = $imageFile;
return $this;
}
}
Поставщик моей сущности:
<?php
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\Collection;
use Doctrine\Common\Collections\ArrayCollection;
use Symfony\Component\HttpFoundation\File\File;
use Symfony\Component\Validator\Constraints as Assert;
/**
* @ORM\Table(name="provider")
* @ORM\Entity(repositoryClass="App\Repository\ProviderRepository")
*/
class Provider extends User
{
/**
* @ORM\Column(type="string", length=255)
* @Assert\NotBlank(message="Veuillez renseigner le nom de l'entreprise")
*/
private $name;
/**
* @ORM\Column(type="string", length=255, nullable=true)
* @Assert\NotBlank()
* @Assert\Email(message="L'email '{{ value }}' n'est pas valide, veuillez vérifier")
*/
private $emailContact;
/**
* @ORM\Column(type="string", length=255, nullable=true)
* @Assert\NotBlank()
* @Assert\Regex(
* pattern="/^((\+|00)32\s?|0)4(60|[789]\d)(\s?\d{2}){3}$/",
* message="Le numéro de téléphone '{{ value }}' n'est pas valide.")
*/
private $phone;
/**
* @ORM\Column(type="string", length=255)
* @Assert\NotBlank()
* @Assert\Regex(
* pattern="/(BE)?0[0-9]{9}/",
* message="Le numéro de TVA '{{ value }}' n'est pas valide.")
*/
private $tva;
/**
* @ORM\Column(type="string", length=255, nullable=true)
* @Assert\NotBlank()
* @Assert\Url(message="Veuillez renseigner une url valide")
*/
private $web;
/**
* @ORM\ManyToMany(targetEntity="App\Entity\Services", inversedBy="providers")
*/
private $services;
/**
* @ORM\OneToMany(targetEntity="App\Entity\Stage", mappedBy="provider", orphanRemoval=true)
*/
private $stages;
/**
* @ORM\OneToMany(targetEntity="App\Entity\Logos", mappedBy="Provider")
*/
private $logos;
public function __construct()
{
$this->services = new ArrayCollection();
$this->stages = new ArrayCollection();
$this->logos = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(string $name): self
{
$this->name = $name;
return $this;
}
public function getEmailContact(): ?string
{
return $this->emailContact;
}
public function setEmailContact(?string $emailContact): self
{
$this->emailContact = $emailContact;
return $this;
}
public function getPhone(): ?string
{
return $this->phone;
}
public function setPhone(?string $phone): self
{
$this->phone = $phone;
return $this;
}
public function getTva(): ?string
{
return $this->tva;
}
public function setTva(string $tva): self
{
$this->tva = $tva;
return $this;
}
public function getWeb(): ?string
{
return $this->web;
}
public function setWeb(?string $web): self
{
$this->web = $web;
return $this;
}
/**
* @return Collection|Services[]
*/
public function getServices(): Collection
{
return $this->services;
}
public function addService(Services $service): self
{
if (!$this->services->contains($service)) {
$this->services[] = $service;
}
return $this;
}
public function removeService(Services $service): self
{
if ($this->services->contains($service)) {
$this->services->removeElement($service);
}
return $this;
}
/**
* @return Collection|Stage[]
*/
public function getStages(): Collection
{
return $this->stages;
}
public function addStage(Stage $stage): self
{
if (!$this->stages->contains($stage)) {
$this->stages[] = $stage;
$stage->setProvider($this);
}
return $this;
}
public function removeStage(Stage $stage): self
{
if ($this->stages->contains($stage)) {
$this->stages->removeElement($stage);
// set the owning side to null (unless already changed)
if ($stage->getProvider() === $this) {
$stage->setProvider(null);
}
}
return $this;
}
public function __toString(){
return $this->name;
}
/**
* @return Collection|Logos[]
*/
public function getLogos(): Collection
{
return $this->logos;
}
public function addLogo(Logos $logo): self
{
if (!$this->logos->contains($logo)) {
$this->logos[] = $logo;
$logo->setProvider($this);
}
return $this;
}
public function removeLogo(Logos $logo): self
{
if ($this->logos->contains($logo)) {
$this->logos->removeElement($logo);
// set the owning side to null (unless already changed)
if ($logo->getProvider() === $this) {
$logo->setProvider(null);
}
}
return $this;
}
}
Моя форма:
<?php
namespace App\Form;
use App\Entity\CodePostal;
use App\Entity\Localite;
use App\Entity\Provider;
use App\Entity\Services;
use App\Entity\Logos;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\CollectionType;
use Symfony\Component\Form\Extension\Core\Type\EmailType;
use Symfony\Component\Form\Extension\Core\Type\FileType;
use Symfony\Component\Form\Extension\Core\Type\NumberType;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\Form\Extension\Core\Type\TelType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\Extension\Core\Type\UrlType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Vich\UploaderBundle\Form\Type\VichFileType;
use Vich\UploaderBundle\Form\Type\VichImageType;
class AccountProType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('name', TextType::class, array(
'label' => ' ',
'attr' => array(
'class' => 'form-control',
'placeholder' => ' ',
),
))
->add('adress', TextType::class, array(
'label' => ' ',
'attr' => array(
'class' => 'form-control',
'placeholder' => ' ',
),
))
->add('adressNumber', NumberType::class, array(
'label' => ' ',
'attr' => array(
'class' => 'form-control',
'placeholder' => ' ',
),
))
->add('codePostal', EntityType::class, array(
'label' =>' ',
'class' => CodePostal::class,
'placeholder' => 'Code Postal ',
'empty_data' => null,
'attr' => array('class' => 'form-control'),
))
->add('localite', EntityType::class, array(
'label' =>' ',
'class' => Localite::class,
'placeholder' => 'Localite ',
'empty_data' => null,
'attr' => array('class' => 'form-control'),
))
->add('phone', TelType::class, array(
'label' => ' ',
'attr' => array(
'class' => 'form-control',
'placeholder' => ' ',
),
))
->add('web', UrlType::class, array(
'label' => ' ',
'attr' => array(
'class' => 'form-control',
'placeholder' => ' ',
),
))
->add('email', EmailType::class, array(
'label' => ' ',
'attr' => array(
'class' => 'form-control',
'placeholder' => ' ',
),
))
->add('emailContact', EmailType::class, array(
'label' => ' ',
'attr' => array(
'class' => 'form-control',
'placeholder' => ' ',
),
))
->add('tva', TextType::class, array(
'label' => ' ',
'attr' => array(
'class' => 'form-control',
'placeholder' => ' ',
),
))
->add('services', EntityType::class, array(
'label' =>' ',
'class' => Services::class,
'placeholder' => ' ',
//'empty_data' => null,
'multiple' => true,
'attr' => array('class' => 'form-control'),
))
->add('imageFile', VichImageType::class,[
'required' => false
])
->add('submit',SubmitType::class)
;
}
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults([
'data_class' => Provider::class,
]);
}
}
Можете ли вы мне помочь, пожалуйста?
Спасибо.