如何在 hautelook 固定装置中将 current() 传递给模板

问题描述

我使用的是 Symfony 3.4 和这个包 https://github.com/hautelook/AliceBundle

这是我的 YAML 文件

AppBundle\Entity\Product:
  template_product (template):
    unit:              !PHP/const AppBundle\Entity\ItemInterface::UNIT_PCS

  product_teeth_{1} (extends template_product):
    name:              Răng sứ kim loại Mỹ ( BH 3 năm )
    price:             1500000
    categoryProducts : ["@category_product_<current()>_1","@category_product_<current()>_2"]
    storeItems:        ["@store_product_<current()>_1","@store_product_<current()>_2"]

  product_teeth_{2} (extends template_product):
    name:              Răng sứ Vita Đức ( BH 4 năm )
    price:             1800000
    categoryProducts : ["@category_product_<current()>_1","@store_product_<current()>_2"]

  product_teeth_{3} (extends template_product):
    name:              Răng toàn sứ Zirconia ( CAD/CAM ) ( BH 7 năm )
    price:             3900000
    categoryProducts : ["@category_product_<current()>_1","@store_product_<current()>_2"]

  product_teeth_{4} (extends template_product):
    name:              Răng sứ Titan ( BH 5 năm )
    price:             2400000
    categoryProducts : ["@category_product_<current()>_1","@store_product_<current()>_2"]

  product_teeth_{5} (extends template_product):
    name:              Răng toàn sứ Full Zirconia ( CAD/CAM ) ( BH 10 năm )
    price:             4400000
    categoryProducts : ["@category_product_<current()>_1","@store_product_<current()>_2"]

  product_teeth_{6} (extends template_product):
    name:              Răng toàn sứ Lava Plus - Ceramay (BH 20 năm)
    price:             1200000
    categoryProducts : ["@category_product_<current()>_1","@store_product_<current()>_2"]

AppBundle\Entity\CategoryProduct:
  template_category_product (template):
    id:       <(substr(md5(uniqid(rand(),true)),18))>

  template_category_1 (template,extends template_category_product):
    category: "@category_product"
  template_category_2 (template,extends template_category_product):
    category: "@category_product_1"

  category_product_{1..3}_1 (extends template_category_1):
    item:     "@product_teeth_<current()>"
  category_product_{1..3}_2 (extends template_category_2):
    item:     "@product_teeth_<current()>"

AppBundle\Entity\StoreProduct:
  template_store_product (template):
    id:       <(substr(md5(uniqid(rand(),18))>

  template_store_1 (template,extends template_store_product):
    store:    "@store_dentist_1"
  template_store_2 (template,extends template_store_product):
    store:    "@store_dentist_2"

  store_product_{1..3}_1 (extends template_store_1):
    item:     "@product_teeth_<current()>"
  store_product_{1..3}_2 (extends template_store_2):
    item:     "@product_teeth_<current()>"

问题是,正如您看到的这些行。他们重复多次:

    categoryProducts : ["@category_product_<current()>_1","@store_product_<current()>_2"]

我不知道如何将 <current()> 传递给模板以减少行数。

谁能告诉我怎么做?

有什么办法可以解决我的问题吗?

我没有被卡住,但是在使用设备库时尝试在 YAML 中做最佳实践 DRY

解决方法

我尝试了一些解决方案后得到了答案。

composer 应该放在最后

例如类别应该是这样的:

--ignore-platform-reqs

和产品

current()

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...