我将在订阅服务器中使用自定义实体关联字段。但我得到这个错误:第一个月
Subscriber.php:
class Subscriber implements EventSubscriberInterface
{
private EntityRepository $myfilter_property_group_option_tagRepository;
public function __construct(EntityRepository $myfilter_property_group_option_tagRepository)
{
$this->myfilter_property_group_option_tagRepository = $myfilter_property_group_option_tagRepository;
}
public static function getSubscribedEvents(): array
{
return [
ProductListingCriteriaEvent::class => [
['onListingCriteria', -200],
],
];
}
public function onListingCriteria(ProductListingCriteriaEvent $event): void
{
$context = $event->getContext();
$optiontags = $this->myfilter_property_group_option_tagRepository->search(new Criteria(), $context);
$event->getContext()->addExtension('optionTags', new ArrayEntity($optiontags));
// Further
$event->getCriteria()->addAssociation('properties');
$event->getCriteria()->addAssociation('properties.group');
$criteria = $event->getCriteria();
$filters = $criteria->getExtension('filters');
if (!$filters instanceof FilterCollection) {
return;
}
$propertyFilter = $filters->get('properties');
// More
字符串
services.xml:
<service id="MyFilter\Subscriber\Subscriber">
<tag name="kernel.event_subscriber"/>
<argument type="service" id="myfilter_property_group_option_tag.repository"/>
</service>
型
有人知道我做错了什么吗?
此外,在管理组件中已创建此实体的扩展。可以用那个吗?
1条答案
按热度按时间7qhs6swi1#
myfilter_property_group_option_tag
基于Map定义,推测Mapproperty_group_option
和tag
实体。Map本身无法获取。改为获取Map两侧的实体。字符串