Quantcast
Channel: Active questions tagged symfony4 - Stack Overflow
Viewing all articles
Browse latest Browse all 3925

Argument must be instance of App\Entity\App\Entity\Categories, Proxies\__CG__\App\Entity\Categories given

$
0
0

I'm rewriting an old symfony 3 project to symfony 4 and I'm trying to rewrite old fixtures to a new format.

Currently, fixtures are working fine for the most of the files, except for a single one where I got the error: Argument 1 passed to App\Entity\Contents::setCategory() must be an instance of App\Entity\App\Entity\Categories or null, instance of Proxies\__CG__\App\Entity\Categories given. In the first fixture file (below), the error is in the second line:

    $contents1_1 = new Contents();    $contents1_1->setCategory($this->getReference('category-budget'));    ...    $manager->persist($contents1_1);

I'm defining 'category-budget' in the second file as follows:

    $categoryBudget = new Categories();    $categoryBudget->setParent($categoryAbout);    $categoryBudget->setType($this->getReference('type-contents'));    ...    $manager->persist($categoryBudget);    $this->addReference('category-budget', $categoryBudget);

type-contents are just dummy data. $categoryAbout is another object of class Categories, with no parent and type-contents set as type.

My setCategory is as follows:

/** * Set category * * @param Categories|null $category * * @return Contents */public function setCategory(Categories $category = null){    $this->category = $category;    return $this;}

What is the issue and how to solve it?


Viewing all articles
Browse latest Browse all 3925

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>