przewiń do treści

Symfony 2 od podstaw

Włodzimierz Gajda

<?php

namespace My\FrontendBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;

class DefaultController extends Controller
{
    /**
     * Lists all Mountain entities.
     *
     * @Route("/", name="frontend")
     * @Template()
     */
    public function indexAction()
    {
        $em = $this->getDoctrine()->getEntityManager();

        $entities = $em->getRepository('MyBackendBundle:Mountain')->findAll();

        return array('entities' => $entities);
    }
}

Listing 39.1. Kontroler DefaultController pakietu FrontendBundle

Rozdział 39. Aplikacja dostępna publicznie w trybie do odczytu

listing-39-01.txt

Reklama

Szkolenia z Symfony 2.1
©2012 Włodzimierz Gajda
ver. 1.0.1