无法生成我的装置alice hautelook symfony既不是属性“ productType”,也不是方法“ getProductType”之一

如何解决无法生成我的装置alice hautelook symfony既不是属性“ productType”,也不是方法“ getProductType”之一

我无法在symfony项目中生成固定装置。 以前,我有一个属性OnetoMany,并传递给ManytoMany。 我认为该错误来自此处。

我用alice装置包{https://github.com/hautelook/AliceBundle

生成装置

我使用这个命令:

./bin/console hautelook:fixtures:load --no-interaction --purge-with-truncate

此结果:

  Neither the property "productType" nor one of the methods "getProductType()","productType()","isProductType()","hasProductType()","__get()" exist and have public access in class "App\Entity\Product".  

我关注的实体:

<?php

declare(strict_types = 1);

namespace App\Entity;

use ApiPlatform\Core\Annotation\ApiResource;
use App\Annotation\Cached;
use App\Traits\ContentEntityTrait;
use App\Traits\SeoTrait;
use DateTime;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\ORM\Mapping\JoinTable;
use Exception;
use JsonSerializable;
use Serializable;
use Symfony\Component\HttpFoundation\File\File;
use Symfony\Component\HttpFoundation\File\UploadedFile;
use Symfony\Component\Validator\Constraints as Assert;
use Vich\UploaderBundle\Mapping\Annotation as Vich;

/**
 * Class Product
 *
 * @ORM\Table()
 * @ORM\Entity(repositoryClass="App\Repository\ProductRepository")
 *
 * @Vich\Uploadable
 * @Cached()
 *
 * @SuppressWarnings(PHPMD.TooManyFields)
 */
class Product implements Serializable,JsonSerializable
{
    use ContentEntityTrait;
    use SeoTrait;

    //<editor-fold desc="Members">

    /**
     * @var string
     *
     * @ORM\Column(type="text")
     *
     * @Assert\NotBlank()
     */
    protected $description;

    /**
     * @var string
     *
     * @ORM\Column(type="string",nullable=true)
     */
    protected $packaging;

    /**
     * @var string
     *
     * @ORM\Column(type="string",nullable=true)
     */
    protected $packing;

    /**
     * @var string
     *
     * @ORM\Column(type="string",nullable=true)
     */
    protected $gencod;

    /**
     * @Vich\UploadableField(mapping="product_picture",fileNameProperty="picture")
     *
     * @Assert\Image(mimeTypes = {
     *          "image/png",*          "image/jpeg",*          "image/jpg",*      })
     *
     * @var File
     */
    protected $pictureFile;

    /**
     * @var string
     *
     * @Assert\Length(max=100)
     *
     * @ORM\Column(type="string",length=100)
     */
    protected $picture;

    /**
     * @var string
     *
     * @Assert\Length(max=255)
     *
     * @ORM\Column(type="string",length=255,nullable=true)
     */
    protected $pdf;

    /**
     * @var File
     *
     * @Assert\File(mimeTypes = {"application/pdf","application/x-pdf"})
     *
     * @Vich\UploadableField(mapping="product_pdf",fileNameProperty="pdf")
     */
    protected $pdfFile;

    /**
     * @var Brand
     *
     * @ORM\ManyToOne(targetEntity="App\Entity\Brand",inversedBy="products")
     */
    protected $brand;

    /**
     * @var Collection|ProductType[]
     * @Assert\Count(min=1,minMessage="Il faut sélectionner au moins {{ limit }} élément")
     * @ORM\ManyToMany(targetEntity="App\Entity\Product",inversedBy="products")
     * @JoinTable(name="product_product_type")
     */
    protected $productTypes;

    /**
     * @var Collection|Sector[]
     *
     * @Assert\Count(min=1,minMessage="Il faut sélectionner au moins {{ limit }} élément")
     *
     * @ORM\ManyToMany(targetEntity="App\Entity\Sector")
     */
    protected $sectors;

    /**
     * @var GemRcn[]
     *
     * @Assert\Count(min=1,minMessage="Il faut sélectionner au moins {{ limit }} élément")
     *
     * @ORM\ManyToMany(targetEntity="App\Entity\GemRcn",inversedBy="products")
     */
    protected $gemRcns;

    /**
     * @var Collection|Sample[]
     *
     * @ORM\OneToMany(targetEntity="App\Entity\Sample",mappedBy="product",cascade={"remove"})
     */
    protected $samples;

    /**
     * @var Collection|Product[]
     *
     * @ORM\ManyToMany(targetEntity="App\Entity\Product")
     */
    protected $products;

    /**
     * @var Collection|Inspiration[]
     *
     * @ORM\ManyToMany(targetEntity="App\Entity\Inspiration")
     */
    protected $inspirations;
    /**
     * @var Collection|Product[]
     * Many Product have many Product.
     * @ORM\ManyToMany(targetEntity="App\Entity\Product")
     * @ORM\JoinTable(name="product_scoring",*      joinColumns={@ORM\JoinColumn(name="current_product",referencedColumnName="id")},*      inverseJoinColumns={@ORM\JoinColumn(name="next_product",referencedColumnName="id")}
     *      )
     */
    protected $scoring;

    /**
     * @var User[]
     *
     * @ORM\ManyToMany(targetEntity="App\Entity\User",mappedBy="products")
     */
    protected $users;

    /**
     * @var bool
     *
     * @ORM\Column(type="boolean",options={"default": true})
     */
    protected $enabled = true;

    /**
     * @var bool
     *
     * Field not mapped
     */
    protected $favorite = false;

    /**
     * @var string
     *
     * Field not mapped
     */
    protected $picturePath;

    /**
     * @var string
     *
     * Field not mapped
     */
    protected $previewPath;

    //</editor-fold>

    /**
     * Product constructor.
     */
    public function __construct()
    {
        $this->sectors   = new ArrayCollection();
        $this->productTypes = new ArrayCollection();
        $this->samples   = new ArrayCollection();
        $this->products  = new ArrayCollection();
        $this->users     = new ArrayCollection();
        $this->gemRcns   = new ArrayCollection();
        $this->scoring   = new ArrayCollection();
    }

    /**
     * @param User $user
     *
     * @return bool
     */
    public function toggleUser(User $user): bool
    {
        if ($this->isFavorite($user)) {
            $this->removeUser($user);

            return false;
        }

        $this->addUser($user);

        return true;
    }

    /**
     * @param User $user
     *
     * @return bool
     */
    public function isFavorite(?User $user): bool
    {
        return $this->users->contains($user);
    }

    /**
     * {@inheritdoc}
     */
    public function jsonSerialize(): array
    {
        return [
            'id'          => $this->id,'title'       => $this->title,'slug'        => $this->slug,'packaging'   => $this->packaging,'brand'       => $this->brand->__toString(),'isFavorite'  => $this->favorite,'picturePath' => $this->picturePath,'previewPath' => $this->previewPath,'picture' => $this->picture
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function serialize()
    {
        return serialize([
            $this->id,$this->title,$this->slug,]);
    }

    /**
     * {@inheritdoc}
     */
    public function unserialize($serialized)
    {
        list(
            $this->id,) = unserialize($serialized,['allowed_classes' => true]);
    }

    //<editor-fold desc="Getters">

    /**
     * @return null|File
     */
    public function getPictureFile(): ?File
    {
        return $this->pictureFile;
    }

    /**
     * @return null|string
     */
    public function getPicture(): ?string
    {
        return $this->picture;
    }

    /**
     * @return string
     */
    public function getPdf(): ?string
    {
        return $this->pdf;
    }

    /**
     * @return File
     */
    public function getPdfFile(): ?File
    {
        return $this->pdfFile;
    }

    /**
     * @return string
     */
    public function getDescription(): ?string
    {
        return $this->description;
    }

    /**
     * @return string
     */
    public function getPackaging(): ?string
    {
        return $this->packaging;
    }

    /**
     * @return string
     */
    public function getPacking(): ?string
    {
        return $this->packing;
    }

    /**
     * @return string
     */
    public function getGencod(): ?string
    {
        return $this->gencod;
    }

    /**
     * @return Brand
     */
    public function getBrand(): ?Brand
    {
        return $this->brand;
    }

    /**
     * @return ProductType[]|Collection
     */
    public function getProductTypes(): Collection
    {
        return $this->productTypes;
    }

    /**
     * @return Sector[]|Collection
     */
    public function getSectors(): Collection
    {
        return $this->sectors;
    }

    /**
     * @return Product[]|Collection
     */
    public function getProducts(): Collection
    {
        return $this->products;
    }

    /**
     * @return GemRcn[]|Collection
     */
    public function getGemRcns(): Collection
    {
        return $this->gemRcns;
    }

    /**
     * @return bool
     */
    public function isEnabled(): bool
    {
        return $this->enabled;
    }
    //</editor-fold>

    //<editor-fold desc="Setters">
    /**
     * @param string $picture
     *
     * @return static
     */
    public function setPicture(?string $picture): self
    {
        $this->picture = $picture;

        return $this;
    }

    /**
     * @param File $pictureFile
     *
     * @return static
     * @throws Exception
     */
    public function setPictureFile(?File $pictureFile): self
    {
        $this->pictureFile = $pictureFile;
        if ($pictureFile instanceof UploadedFile && $pictureFile->getError() === 0) {
            $this->updatedAt = new DateTime();
        }

        return $this;
    }

    /**
     * @param string $pdf
     *
     * @return self
     */
    public function setPdf(?string $pdf): self
    {
        $this->pdf = $pdf;

        return $this;
    }

    /**
     * @param File $pdfFile
     *
     * @return self
     * @throws Exception
     */
    public function setPdfFile(?File $pdfFile): self
    {
        $this->pdfFile = $pdfFile;
        if ($pdfFile instanceof UploadedFile && $pdfFile->getError() === 0) {
            $this->updatedAt = new DateTime();
        }

        return $this;
    }

    /**
     * @param string $description
     *
     * @return self
     */
    public function setDescription(string $description): self
    {
        $this->description = $description;

        return $this;
    }

    /**
     * @param string $packaging
     *
     * @return self
     */
    public function setPackaging(string $packaging): self
    {
        $this->packaging = $packaging;

        return $this;
    }

    /**
     * @param string $packing
     *
     * @return self
     */
    public function setPacking(string $packing): self
    {
        $this->packing = $packing;

        return $this;
    }

    /**
     * @param string $gencod
     *
     * @return self
     */
    public function setGencod(string $gencod): self
    {
        $this->gencod = $gencod;

        return $this;
    }

    /**
     * @param Brand $brand
     *
     * @return self
     */
    public function setBrand(Brand $brand): self
    {
        $this->brand = $brand;

        return $this;
    }

    /**
     * @param ProductType $productType
     *
     * @return self
     */
    public function addProductType(ProductType $productType): self
    {
        $this->productTypes->add($productType);

        return $this;
    }

    /**
     * @param bool $enabled
     *
     * @return self
     */
    public function setEnabled(bool $enabled): self
    {
        $this->enabled = $enabled;

        return $this;
    }

    /**
     * @param bool $isFavorite
     *
     * @return self
     */
    public function setFavorite(bool $isFavorite): self
    {
        $this->favorite = $isFavorite;

        return $this;
    }

    /**
     * @param string $path
     *
     * @return self
     */
    public function setPicturePath(string $path): self
    {
        $this->picturePath = $path;

        return $this;
    }

    /**
     * @param string $path
     *
     * @return self
     */
    public function setPreviewPath(string $path): self
    {
        $this->previewPath = $path;

        return $this;
    }
    //</editor-fold>

    //<editor-fold desc="Collection">
    /**
     * @param Sector $sector
     *
     * @return self
     */
    public function removeSector(Sector $sector): self
    {
        $this->sectors->removeElement($sector);

        return $this;
    }

    /**
     * @param ProductType $productType
     *
     * @return self
     */
    public function removeProductType(ProductType $productType): self
    {
        $this->productTypes->removeElement($productType);

        return $this;
    }

    /**
     * @param Sector $sector
     *
     * @return self
     */
    public function addSector(Sector $sector): self
    {
        $this->sectors->add($sector);

        return $this;
    }

    /**
     * @param Sample $sample
     *
     * @return self
     */
    public function removeSample(Sample $sample): self
    {
        $this->samples->removeElement($sample);

        return $this;
    }

    /**
     * @param Sample $sample
     *
     * @return self
     */
    public function addSample(Sample $sample): self
    {
        $this->samples->add($sample);

        return $this;
    }

    /**
     * @param Product $product
     *
     * @return self
     */
    public function removeProduct(Product $product): self
    {
        $this->products->removeElement($product);

        return $this;
    }

    /**
     * @param Product $product
     *
     * @return self
     */
    public function addProduct(Product $product): self
    {
        $this->products->add($product);

        return $this;
    }

    /**
     * @param User $user
     *
     * @return self
     */
    public function addUser(User $user): self
    {
        $this->users->add($user);
        $user->addProduct($this);

        return $this;
    }

    /**
     * @param User $user
     *
     * @return self
     */
    public function removeUser(User $user): self
    {
        $this->users->removeElement($user);
        $user->removeProduct($this);

        return $this;
    }

    /**
     * @param GemRcn $gemRcn
     *
     * @return self
     */
    public function addGemRcn(GemRcn $gemRcn): self
    {
        $this->gemRcns->add($gemRcn);
        $gemRcn->addProduct($this);

        return $this;
    }

    /**
     * @param GemRcn $gemRcn
     *
     * @return self
     */
    public function removeGemRcn(GemRcn $gemRcn): self
    {
        $this->gemRcns->removeElement($gemRcn);
        $gemRcn->removeProduct($this);

        return $this;
    }

    public function getScoring(){
        return $this->scoring;
    }

    /**
     * @param Product $product
     * @return Product
     */
    public function addScoring(Product $product) :self
    {
        $this->scoring->add($product);
        return $this;
    }

    /**
     * @param Product $product
     * @return self
     */
    public function removeScoring(Product $product): self
    {
        $this->scoring->removeElement($product);
        return $this;
    }
}

我的另一个实体(ManytoMany):

<?php

declare(strict_types = 1);

namespace App\Entity;

use App\Annotation\Cached;
use App\Traits\ContentEntityTrait;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;



/**
 * Class ProductType
 *
 * @ORM\Table()
 * @ORM\Entity(repositoryClass="App\Repository\ProductTypeRepository")
 *
 * @UniqueEntity(fields={"title","universe"})
 *
 * @Cached()
 */
class ProductType implements \JsonSerializable
{
    use ContentEntityTrait;

    //<editor-fold desc="Members">
    /**
     * @var Universe
     *
     * @ORM\ManyToOne(targetEntity="App\Entity\Universe",inversedBy="productTypes",cascade={"persist"})
     */
    protected $universe;

    /**
     * @var Product[]
     *
     * @ORM\ManyToMany(targetEntity="App\Entity\Product",mappedBy="productTypes",cascade={"remove"})
     */
    protected $products;
    //</editor-fold>

    /**
     * Product Type constructor.
     */
    public function __construct()
    {
        $this->products = new ArrayCollection();
    }

    /**
     * {@inheritdoc}
     */
    public function jsonSerialize(): array
    {
        return [
            'id'    => $this->id,'title' => $this->title,];
    }

    //<editor-fold desc="Getters">

    /**
     * @return Product[]
     */
    public function getProducts()
    {
        return $this->products;
    }

    /**
     * @return Universe
     */
    public function getUniverse(): ?Universe
    {
        return $this->universe;
    }
    //</editor-fold>

    //<editor-fold desc="Setters">
    /**
     * @param Universe $universe
     *
     * @return self
     */
    public function setUniverse(Universe $universe): self
    {
        $this->universe = $universe;
        $universe->addProductType($this);

        return $this;
    }
    //</editor-fold>

    //<editor-fold desc="Collection">
    /**
     * @param Product $product
     *
     * @return self
     */
    public function addProduct(Product $product): self
    {
        $this->products->add($product);

        return $this;
    }

    /**
     * @param Product $product
     *
     * @return self
     */
    public function removeProduct(Product $product): self
    {
        $this->products->removeElement($product);

        return $this;
    }


    //</editor-fold>
}

我的装置Yaml:

App\Entity\Product:
    product_{1..40}:
        title: '<sentence(3)>'
        description: '<sentence()>'
        packaging: '<sentence(3)>'
        packing: '<sentence(3)>'
        picture: '<fileCopy("features/files/image/test-picture.jpg","public/uploads/products",0)>'
        brand: '@brand_<numberBetween(1,10)>'
        gemRcns: ['@gem_rcn_<numberBetween(1,10)>']
        gencod: '<sentence(3)>'
        productTypes: ['@product_type_<numberBetween(1,21)>','@product_type_<numberBetween(1,21)>']
        sectors: ['@school','@health','@pension','@company','@bakery','@hostel','@retailer']

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


使用本地python环境可以成功执行 import pandas as pd import matplotlib.pyplot as plt # 设置字体 plt.rcParams[&#39;font.sans-serif&#39;] = [&#39;SimHei&#39;] # 能正确显示负号 p
错误1:Request method ‘DELETE‘ not supported 错误还原:controller层有一个接口,访问该接口时报错:Request method ‘DELETE‘ not supported 错误原因:没有接收到前端传入的参数,修改为如下 参考 错误2:cannot r
错误1:启动docker镜像时报错:Error response from daemon: driver failed programming external connectivity on endpoint quirky_allen 解决方法:重启docker -&gt; systemctl r
错误1:private field ‘xxx‘ is never assigned 按Altʾnter快捷键,选择第2项 参考:https://blog.csdn.net/shi_hong_fei_hei/article/details/88814070 错误2:启动时报错,不能找到主启动类 #
报错如下,通过源不能下载,最后警告pip需升级版本 Requirement already satisfied: pip in c:\users\ychen\appdata\local\programs\python\python310\lib\site-packages (22.0.4) Coll
错误1:maven打包报错 错误还原:使用maven打包项目时报错如下 [ERROR] Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:3.2.0:resources (default-resources)
错误1:服务调用时报错 服务消费者模块assess通过openFeign调用服务提供者模块hires 如下为服务提供者模块hires的控制层接口 @RestController @RequestMapping(&quot;/hires&quot;) public class FeignControl
错误1:运行项目后报如下错误 解决方案 报错2:Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project sb 解决方案:在pom.
参考 错误原因 过滤器或拦截器在生效时,redisTemplate还没有注入 解决方案:在注入容器时就生效 @Component //项目运行时就注入Spring容器 public class RedisBean { @Resource private RedisTemplate&lt;String
使用vite构建项目报错 C:\Users\ychen\work&gt;npm init @vitejs/app @vitejs/create-app is deprecated, use npm init vite instead C:\Users\ychen\AppData\Local\npm-
参考1 参考2 解决方案 # 点击安装源 协议选择 http:// 路径填写 mirrors.aliyun.com/centos/8.3.2011/BaseOS/x86_64/os URL类型 软件库URL 其他路径 # 版本 7 mirrors.aliyun.com/centos/7/os/x86
报错1 [root@slave1 data_mocker]# kafka-console-consumer.sh --bootstrap-server slave1:9092 --topic topic_db [2023-12-19 18:31:12,770] WARN [Consumer clie
错误1 # 重写数据 hive (edu)&gt; insert overwrite table dwd_trade_cart_add_inc &gt; select data.id, &gt; data.user_id, &gt; data.course_id, &gt; date_format(
错误1 hive (edu)&gt; insert into huanhuan values(1,&#39;haoge&#39;); Query ID = root_20240110071417_fe1517ad-3607-41f4-bdcf-d00b98ac443e Total jobs = 1
报错1:执行到如下就不执行了,没有显示Successfully registered new MBean. [root@slave1 bin]# /usr/local/software/flume-1.9.0/bin/flume-ng agent -n a1 -c /usr/local/softwa
虚拟及没有启动任何服务器查看jps会显示jps,如果没有显示任何东西 [root@slave2 ~]# jps 9647 Jps 解决方案 # 进入/tmp查看 [root@slave1 dfs]# cd /tmp [root@slave1 tmp]# ll 总用量 48 drwxr-xr-x. 2
报错1 hive&gt; show databases; OK Failed with exception java.io.IOException:java.lang.RuntimeException: Error in configuring object Time taken: 0.474 se
报错1 [root@localhost ~]# vim -bash: vim: 未找到命令 安装vim yum -y install vim* # 查看是否安装成功 [root@hadoop01 hadoop]# rpm -qa |grep vim vim-X11-7.4.629-8.el7_9.x
修改hadoop配置 vi /usr/local/software/hadoop-2.9.2/etc/hadoop/yarn-site.xml # 添加如下 &lt;configuration&gt; &lt;property&gt; &lt;name&gt;yarn.nodemanager.res