【发布时间】:2016-10-31 17:24:24
【问题描述】:
我正在尝试覆盖 ProductController,我已遵循此文档: http://docs.sylius.org/en/stable/bundles/general/overriding_controllers.html 但异常不断出现:
可捕获的致命错误:传递给 Sylius\Bundle\ResourceBundle\Controller\ResourceController::__construct() 的参数 1 必须实现接口 Sylius\Component\Resource\Metadata\MetadataInterface,未给出,在 C:\wamp3\www\ 中调用sidratsoft_website\app\cache\dev\appDevDebugProjectContainer.php 在第 1382 行并定义
AppBundle/Controller/ProductController.php:
<?php
namespace AppBundle\Controller;
use FOS\RestBundle\View\View;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Sylius\Component\Resource\Metadata\MetadataInterface;
use Sylius\Bundle\ResourceBundle\Controller\ResourceController;
use Sylius\Component\Resource\ResourceActions;
class ProductController extends ResourceController
{
public function allProdSpecificTaxonAction(Request $request,$t){
$locale = $this->get('sylius.context.locale')->getLocale();
/** @var Taxon $taxon */
$taxon = $this->get('sylius.repository.taxon')
->findByName('Honeywell',$locale);
var_dump($taxon);
exit;
}
}
?>
app/config/routing.yml:
app_bundle_product:
path: /products/cat/{taxon}
defaults:
_controller: AppBundle:Product:allProdSpecificTaxonAction
app/config/config.yml:
sylius_product:
resources:
product:
classes:
controller: AppBundle\Controller\ProductController
【问题讨论】:
标签: sylius