路径" sylius_cart.resources.cart.classes.form"的类型无效。预期的数组,但得到字符串symfony 2.8.3 sylius 0.17.0

时间:2016-03-08 15:52:49

标签: php symfony sylius

这是一个非常明确的错误消息,但由于某些原因,我无法绕过它。

config:

sylius_cart:
# The driver used for persistence layer.
driver: ~
# Service id of cart item resolver.
resolver: app.cart_item_resolver
# Cart provider service id.
provider: sylius.cart_provider.default
# The id of cart storage for default provider.
storage: sylius.cart_storage.session
resources:
    cart:
        classes:
            controller: Sylius\Bundle\CartBundle\Controller\CartController
            form:       Sylius\Bundle\CartBundle\Form\Type\CartType
        validation_groups:
            default: [ sylius ]
    cart_item:
        classes:
            controller: Sylius\Bundle\CartBundle\Controller\CartItemController
            form:       Sylius\Bundle\CartBundle\Form\Type\CartItemType
        validation_groups:
            default: [ sylius ]

当我跑

  

$ php app / console doctrine:schema:update --force

我收到错误:

  

[Symfony \ Component \ Config \ Definition \ Exception \ InvalidTypeException] path" sylius_cart.resources.cart.classes.form"的类型无效。预期的数组,但得到了字符串

1 个答案:

答案 0 :(得分:2)

正如您在Configuration中所看到的,sylius_cart.resources.cart.classes.form期望一个数组的密钥为default

->arrayNode('form')
    ->addDefaultsIfNotSet()
    ->children()
        ->scalarNode('default')->defaultValue(CartType::class)->cannotBeEmpty()->end()
    ->end()
->end()

您需要将配置更改为

//...
resources:
    cart:
        classes:
            controller: Sylius\Bundle\CartBundle\Controller\CartController
            form:
                default: Sylius\Bundle\CartBundle\Form\Type\CartType
        validation_groups:
            default: [ sylius ]
    cart_item:
        classes:
            controller: Sylius\Bundle\CartBundle\Controller\CartItemController
            form:
                default: Sylius\Bundle\CartBundle\Form\Type\CartItemType
        validation_groups:
            default: [ sylius ]