przewiń do treści

Symfony 2 od podstaw

Włodzimierz Gajda

class DefaultController extends Controller
{
    /**
     * @Route("/")
     * @Template()
     */
    public function indexAction($culture)
    {

        $em = $this->getDoctrine()->getEntityManager();
        $entities = $em->getRepository('MyFrontendBundle:Color')->findAll();

        if ($culture != 'pl') {
            foreach ($entities as $entity) {
                $entity->setTranslatableLocale($culture);
                $em->refresh($entity);
            }
        }

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

Listing 24.8. Kod akcji index

Rozdział 24. Zachowanie translatable

listing-24-08.txt

Reklama

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