问题描述
我想检查单词$ filterwords是否出现在对象之一中,并在我的小部件筛选器中对其进行过滤。
结构如下: 类博客具有n个功能。功能具有名称。
例如:
Blog1
-Feature1
--Name "Fast"
-Feature2
--Name "Beautiful"
Blog2
-Feature1
--Name "Fast"
Blog3
-Feature2
--Name "Beautiful"
现在,我希望所有具有“快速”属性的博客。
在List.html中,我实际上想这样称呼我的过滤器:
<example:widget.myfilter objects="{blogs}" as="filteredblogs" property="features.name">
但这是不可能的,因为要素是n个对象。 “在关系匹配中使用了不支持或不存在的属性名称“名称”。
因此它只能这样工作:
<example:widget.myfilter objects="{blogs}" as="filteredblogs" property="features">
所以在我的小部件过滤器控制器中,我得到的属性是这样的:
/**
* @var QueryResultInterface
*/
protected $objects;
public function initializeAction()
{
$this->objects = $this->widgetConfiguration['objects'];
$this->property = $this->widgetConfiguration['property'];
$this->as = $this->widgetConfiguration['as'];
}
/**
* @param string $filterword
*/
public function indexAction(string $filterword = ""): void
{
$query = $this->objects->getQuery();
$query->matching($query->contains($this->property,$filterword));
...
现在的问题是“包含”查询不起作用,因为他必须检查属性“功能”->“名称”。但是它不会将“ Feature.name”作为属性传递,而只会传递“ features”。您必须以某种方式告诉“包含”它应该检查“名称”。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)