I'm getting this error which I think I get when trying to access any Entity Repository.
An exception has been thrown during the rendering of a template ("Cache key "App:Category__CLASSMETADATA__" contains reserved characters "{}()/@:".").
I loaded the commit when the code last worked and reloaded but I'm still getting this error.
I have tried to find an answer in previous posts but those don't work for me because for example I don't have @Assert anywhere in the code.
I tried going through the composer.json file and update all libraries to latest version, then removing vendor folder and composer update because that worked for someone. But it hasn't worked for me.
I'm using Symfony 5.4 and PHP 8.0.
Category.php
<?php
namespace App\Entity;
use App\Repository\CategoryRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: CategoryRepository::class)]
class Category
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: 'integer')]
private $id;
#[ORM\Column(type: 'string', length: 255)]
private $name;
#[ORM\OneToMany(mappedBy: 'category', targetEntity: Product::class, orphanRemoval: true)]
private $products;
public function __construct()
{
$this->products = 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;
}
/**
* @return Collection<int, Product>
*/
public function getProducts(): Collection
{
return $this->products;
}
public function addProduct(Product $product): self
{
if (!$this->products->contains($product)) {
$this->products[] = $product;
$product->setCategory($this);
}
return $this;
}
public function removeProduct(Product $product): self
{
if ($this->products->removeElement($product)) {
// set the owning side to null (unless already changed)
if ($product->getCategory() === $this) {
$product->setCategory(null);
}
}
return $this;
}
}
I'll be happy to share any information you think might be useful.
Thank you very much in advance.
Edit: I have just downloaded the commit in a different folder and rerun everything but still getting same error message.
CodePudding user response:
Try to replace "App:Category" with "App\Entity\Category" when you call in controllers, forms and repositories.
We expirienced the same issue and the replace worked for us.