0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

既存Controllerの上書き

Posted at

既存の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',
        ];
    }
}

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?