doucaishou0074 2019-04-23 20:37
浏览 78

如何在定义另一个实体属性时使用Entity属性

I need to use a property in one of my entities to set the value of another property in that same entity.

Let me explain myself, i have two properties, one of them is the image name, and the other one is a download link, in order to get a download link i need to take the image name and pass it to a function that would get my download link from the web

I have been looking at the life cycle methods on doctrine, but i cant get it to work, at the moment i only want to dislay that image name into the download link property.

So, the user uploads a file, i get the name of the file back, i take that name and use it to fetch a download link within my download link property.

Im using the "PostPersist" method and again, its just returning a null value when i take a look at my DB

Entity:

/**
 * @ORM\Column(type="text", nullable=true)
 */
private $downloadImage;

//I commented out the setters and getters, cause i dont think i  
//need them since i will be setting the value by default in the
//"PostPersist" method            

PostPersist Method:

/**
* @ORM\PostPersist
*/
public function setDownloadLinkValue ()
{
    $this->downloadImage = $this->getImageName(); //Yes yes, i have tried both, with "getImageName()" and "imageName"
}

I think its a very silly error, but im not 100% sure, if you need something else to see in my code please let me know so i can update this post

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
    • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
    • ¥15 CSAPPattacklab
    • ¥15 一直显示正在等待HID—ISP
    • ¥15 Python turtle 画图
    • ¥15 关于大棚监测的pcb板设计
    • ¥15 stm32开发clion时遇到的编译问题
    • ¥15 lna设计 源简并电感型共源放大器
    • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
    • ¥15 Vue3地图和异步函数使用