0

我正在尝试在 Symfony 2.3 上设置 Sonata Bundles Ecommerce。

我按照此处提到的安装步骤操作,但在尝试加载请求 app_dev.php 的页面时出现错误。

这是错误

FatalErrorException:编译错误:声明 Sonata\ProductBundle\Entity\BaseProduct::validateOneMainCategory() 必须与 /xxx/ 中的 Sonata\Component\Product\ProductInterface::validateOneMainCategory(Symfony\Component\Validator\Context\LegacyExecutionContext $context) 兼容xx/xx/xxxx/vendor/sonata-project/ecommerce/src/ProductBundle/Entity/BaseProduct.php 第 28 行

谁能帮我解决这个问题?

4

2 回答 2

0

我在使用奏鸣曲管理包之前收到此错误消息,我认为您应该注意文件顶部的使用语句。您需要添加适当的使用语句。查看 ProductInterface,您会找到要使用的正确文件.

于 2015-01-27T10:33:36.657 回答
0

我在 ProductInterface 中有这个

    use Symfony\Component\Validator\Context\LegacyExecutionContext;

/**
     * Validates if product has one main category
     *
     * @param LegacyExecutionContext $context
     *
     * @return void
     */
    public function validateOneMainCategory(LegacyExecutionContext $context);

在 BaseProduct.php

use Symfony\Component\Validator\ExecutionContext;

   /**
     * {@inheritdoc}
     */
    public function validateOneMainCategory(LegacyExecutionContext $context)
    {
        if ($this->getCategories()->count() == 0) {
            return;
        }

        if (!$this->hasOneMainCategory()) {
            $context->addViolation('sonata.product.must_have_one_main_category');
        }
    }
于 2015-01-27T10:37:43.577 回答