-
-
Notifications
You must be signed in to change notification settings - Fork 404
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Regenerate doesn't work if there is an Embedded property in Entity #160
Comments
In fact,
|
@welcoMattic Could you please provide your Entity mapping and check your maker-bundle version, I cannot reproduce this bug |
Product.php (Generated entity) namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\HttpFoundation\File\File;
use Vich\UploaderBundle\Mapping\Annotation as Vich;
/**
* @ORM\Entity()
* @Vich\Uploadable
*/
class Product
{
/**
* @ORM\Id()
* @ORM\GeneratedValue()
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=255, unique=true)
*/
private $reference;
/**
* @ORM\Column(type="string", length=255)
*/
private $designation;
/**
* @ORM\Embedded(class="CatalogMedia")
*/
private $mainMedia;
...
} CatalogMedia (Embeddable) <?php
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\HttpFoundation\File\File;
use Vich\UploaderBundle\Mapping\Annotation as Vich;
/**
* @ORM\Embeddable()
* @Vich\Uploadable
*/
class CatalogMedia
{
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $filename;
/**
* @Vich\UploadableField(mapping="catalog_media", fileNameProperty="filename")
*/
private $file;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $altAttribute;
...
} If execute |
Hey @welcoMattic! Thanks for the Can you verify exactly what version of MakerBundle you're using? We thought we squashed this bug in #149, which was included in v1.4.1. Cheers! |
Hi @weaverryan! I just updated the bundle to 1.4.2, and I still get the error message. Here's the complete output of
EDIT: After some of |
I'll check this problem with metedata. However there is another bug with embedded classes, it refers to embedded field names. |
I finally found the cause of this error, and it's not caused by the previous entities. But, by these: namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\HttpFoundation\File\File;
use Vich\UploaderBundle\Mapping\Annotation as Vich;
/**
* @ORM\Embeddable()
* @Vich\Uploadable
*/
class CatalogMedia
{
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $filename;
/**
* @Vich\UploadableField(mapping="catalog_media", fileNameProperty="filename")
*/
private $file;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $altAttribute;
// classic getters and setters
} and namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
use Knp\DoctrineBehaviors\Model as ORMBehaviors;
use Symfony\Component\HttpFoundation\File\File;
/**
* @ORM\Entity(repositoryClass="App\Repository\CarouselProductMediaRepository")
*/
class CarouselProductMedia
{
use ORMBehaviors\Timestampable\Timestampable;
/**
* @ORM\Id()
* @ORM\GeneratedValue()
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Embedded(class="CatalogMedia")
*/
private $productMedia;
public function getId(): ?int
{
return $this->id;
}
public function getProductMedia(): ?CatalogMedia
{
return $this->productMedia;
}
public function setProductMedia(?CatalogMedia $productMedia): self
{
$this->productMedia = $productMedia;
if ($this->productMedia->getFile() instanceof File) {
$this->setUpdatedAt(new \DateTime());
}
return $this;
}
} May be these entities could help us to fix the issue ;) |
@welcoMattic Hi Sorry, but I don't see how you have resolved an issue. I configured classes in the same way like you, but still getting error Notice: Trying to get property of non-object. Can you explain in details? Thanks! |
Hi @dimabory, I haven't fix the issue yet. I'm still working on it on my free time ;) |
Facing the same issue, when using |
@welcoMattic hi, can you please test my bugfix? |
@sadikoff I'll try do test your bug fix this week (next Tuesday is off in France ;) ) |
@welcoMattic Would you expect the class to be generated with a |
@weaverryan I expect neither getter or setter, just regeneration without errors. Then if we can pass an option to generate a getter for embeddable, it's perfect ;) |
I'm getting the same error
My entity:
Maker bundle version: v1.21.1 |
Hello!!
symfony/maker-bundle: 1.21 |
Hi, thanks for maker-bundle, it's a very powerful tool! ❤️
I tried to regenerate an Entity that contains a
@ORM\Embedded()
property.Here the steps to reproduce the bug:
make:entity
with some fields@ORM\Embedded()
property to this entity💥
The output is:
The text was updated successfully, but these errors were encountered: