Доктрина ORM: Где я ошибаюсь с YAML, чтобы определить отношения "многие ко многим"?
Я использую Silex с Doctrine ORM, пытаясь создать сопоставления с базой данных с помощью YAML. У меня есть много-много отношений между categories
а также products
таблицы и хотят иметь категории на стороне владельца. Однако всякий раз, когда я пытаюсь сбросить '$productCategories' в файл ветки,
{% for productCategories in category.productCategories %}
<li><a href=""></a>{{ productCategories.name }}</li>
{% endfor %}
Я получил:
Переменная "productCategories" не существует в "category.twig"
Вот файл Categories.yml:
MVCStore\Entity\Category:
type: entity
table: categories
manyToMany:
productCategories:
targetEntity: MVCStore\Entity\Product
inversedBy: category
joinTable:
name: products_categories
joinColumns:
products:
referencedColumnName: id
inverseJoinColumns:
categories:
referencedColumnName: id
id:
id:
type: integer
generator:
strategy: auto
fields:
name:
type: string
parent_id:
type: integer
А вот файл products.yml:
MVCStore\Entity\Product:
type: entity
table: products
repositoryClass: MVCStore\EntityRepository\Product
oneToMany:
productImages:
targetEntity: MVCStore\Entity\ProductImage
mappedBy: product
manyToMany:
productCategories:
targetEntity: MVCStore\Entity\Category
mappedBy: products
id:
id:
type: integer
generator:
strategy: auto
fields:
stock:
type: integer
name:
type: string
description:
type: string
featured:
type: boolean
price:
type: decimal
Если что-то еще нужно, пожалуйста, спросите.