既存のTOPのControllerを上書きする際の動作メモ
コントローラのカスタマイズ
bin/console eccube:make:controller
Choose a name for your controller class (e.g. DeliciousPizzaController):
> Top
created: app/Customize/Controller/TopController.php
created: app/template/default/top/index.html.twig
Routeとnameを既存と合わせないといけない。
既存のTopController.php
<?php
/*
* This file is part of EC-CUBE
*
* Copyright(c) EC-CUBE CO.,LTD. All Rights Reserved.
*
* http://www.ec-cube.co.jp/
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Eccube\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
use Symfony\Component\Routing\Annotation\Route;
class TopController extends AbstractController
{
/**
* @Route("/", name="homepage")
* @Template("index.twig")
*/
public function index()
{
return [];
}
}
新しいTopController.php
<?php
namespace Customize\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
use Symfony\Component\Routing\Annotation\Route;
final class TopController
{
/**
* @Route("/", name="homepage")
* @Template("top/index.html.twig")
*/
public function index()
{
return [
'controller_name' => 'TopController',
];
}
}