[英]Sonata Bundle Issues [Product Bundle]
I'm trying to set Sonata Bundles Ecommerce on Symfony 2.3. 我正在尝试在Symfony 2.3上设置Sonata Bundles电子商务。
I followed install steps mentionned here but I'm getting an error when trying to load my page requesting app_dev.php. 我按照此处提到的安装步骤进行操作,但是在尝试加载请求app_dev.php的页面时出现错误。
Here is the error 这是错误
FatalErrorException: Compile Error: Declaration of Sonata\\ProductBundle\\Entity\\BaseProduct::validateOneMainCategory() must be compatible with Sonata\\Component\\Product\\ProductInterface::validateOneMainCategory(Symfony\\Component\\Validator\\Context\\LegacyExecutionContext $context) in /xxx/xx/xx/xxxx/vendor/sonata-project/ecommerce/src/ProductBundle/Entity/BaseProduct.php line 28 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行
Can anyone help me to solve this ? 谁能帮我解决这个问题?
我在使用Sonata管理员捆绑包之前收到了此错误消息,我认为您应该注意文件顶部的uses语句。您需要添加适当的use语句。在ProductInterface上查找您将找到要使用的正确文件。
I have this in ProductInterface 我在ProductInterface中有这个
use Symfony\Component\Validator\Context\LegacyExecutionContext;
/**
* Validates if product has one main category
*
* @param LegacyExecutionContext $context
*
* @return void
*/
public function validateOneMainCategory(LegacyExecutionContext $context);
And in BaseProduct.php 并在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');
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.