Synfony2.8 パラメータ受け渡し(Controller ⇒ View)

2020年10月23日 Posted by PURGE

class SceduleController extends Controller
{
    /**
     * @Route("/schedule")
     */
    public function indexAction()
    {
        $scheduleList = [
            [
                "date" => "2020年11月1日",
                "time" => "12:00",
                "place" => "群馬",
            ],
            [
                "date" => "2020年11月2日",
                "time" => "13:30",
                "place" => "横浜",
            ],
            [
                "date" => "2020年11月3日",
                "time" => "18:00",
                "place" => "東京",
            ],
        ];
        return $this->render('AppBundle:Scedule:index.html.twig',
            ['scheduleList' => $scheduleList]
        );
    }
}
{% extends "::base.html.twig" %}

{% block title %}AppBundle:Scedule:index{% endblock %}

{% block body %}
<h1>Game Date</h1>
    <ul>
    {% for schedule in scheduleList %}
        <li>{{ schedule.date }} {{ schedule.time }} {{ schedule.place }}</li>
    {% endfor %}
    </ul>
{% endblock %}

コメントを残す

メールアドレスが公開されることはありません。 * が付いている欄は必須項目です