我知道这个问题很la脚。我有一个实体ContentSelector,另一个是Content Selector中的Content我有一个具有Content的属性Content。我正在尝试访问内容索引,但始终会出错。这就是我想要做的。
$cs = $pages->getContentSelector();
它返回:
[
{
"id": 22,
"title": "my Title",
"content": "11021,10930,10874,10766,10954,10705,10948,10934,11048,11049,10831"
}
]
现在我想获取content属性,例如$cs->content
得到如下错误:
"Notice: Undefined property: Doctrine\\ORM\\PersistentCollection::$content"
尝试使用getContent(); 收到该方法不存在的错误。但是该方法实际上存在于ContentSelector中。
如何轻松获得内容ID?
getContentSelector()方法返回一个ArrayCollection,因此您需要在调用所包含对象的方法之前访问该集合的元素。例如,您可以按以下方式访问第一个元素:
$collection = $pages->getContentSelector();
$cs = $collection->first();
然后,您可以尝试访问objet元素(从转储中似乎是一个json对象?)
希望有帮助
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句