2017 © Pedro PelĆ”ez
 

symfony-bundle translation-form-bundle

This bundle of symfony2

image

baconmanager/translation-form-bundle

This bundle of symfony2

  • Saturday, February 6, 2016
  • by adanfm
  • Repository
  • 3 Watchers
  • 0 Stars
  • 1 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

BaconTranslationFormBundle

Este bundle tem o objetivo de alterar o comportamento do A2lixFormBundle que Ć© utilizado para renderizar o formulario de multi idiomas, (*1)

Funcionalidades Adicionadas

  • Provider para retornar languages de uma determinada Entity
  • Interfaces para implementaĆ§Ć£o do repository e entity
  • FunĆ§Ć£o do twig para renderizar do nome do idioma na aba do formulĆ”rio
  • EventListener para salvar registro dos idiomas que foram adicionado conteĆŗdo
  • ConfiguraĆ§Ć£o da entity que vai conter os idiomas

InstalaĆ§Ć£o

Adicionar no composer a instalaĆ§Ć£o do A2lixFormBundle, (*2)

composer require a2lix/translation-form-bundle

Adicionar as seguintes linhas no arquivo app/AppKernel.php, (*3)

# app/AppKernel.php

public function registerBundles()
{
    $bundles = array(
        // ...
        new A2lix\TranslationFormBundle\A2lixTranslationFormBundle(),
        new A2C\Bundle\TranslationFormBundle\A2CTranslationFormBundle(),
        new Knp\DoctrineBehaviors\Bundle\DoctrineBehaviorsBundle(),
        // ...
    );
}

ConfiguraĆ§Ć£o

ConfiguraĆ§Ć£o do app/config/config.yml, (*4)


# Translate Form a2lix a2lix_translation_form: locale_provider: locale_doctrine_provider locales: [en_US] default_locale: en_US manager_registry: doctrine templating: "BaconTranslationFormBundle::default.html.twig" #Bacon TranslationForm bacon_translation_form: class_language_provider: Bacon\Bundle\LanguageBundle\Entity\Language

Utilizando

Para utilizar vocĆŖ deve implementar as 2 interface disponĆ­veis, (*5)

  • Bacon\Bundle\TranslationFormBundle\Locale\EntityInterface.php
  • Bacon\Bundle\TranslationFormBundle\Locale\RepositoryInterface.php

Deve ficar algo mais ou menos assim:, (*6)

# src/AppBundle/Entity/Language.php

<?php

namespace AppBundle\Entity;

use A2C\Bundle\CoreBundle\Entity\BaseEntity;
use A2C\Bundle\TranslationFormBundle\Locale\EntityInterface;
use Doctrine\ORM\Mapping as ORM;

/**
 * Class Language
 * @ORM\Entity(repositoryClass="AppBundle\Entity\Repository\LanguageRepository")
 * @ORM\Table(name="language")
 */
class Language extends BaseEntity implements EntityInterface
{
    // --------

    /**
     * @ORM\Column(name="acron",type="string",length=2,nullable=false)
     */
    private $acron;

    /**
     * @ORM\Column(name="locale",type="string",length=5,nullable=false)
     */
    private $locale;

    public function getAcron()
    {
        return $this->acron;
    }

    public function getLocale()
    {
        return $this->locale;
    }

    // --------
}
# src/AppBundle/Entity/Repository/LanguageRepository.php

<?php

namespace AppBundle\Entity\Repository;

use Bacon\Bundle\TranslationFormBundle\Locale\RepositoryInterface;
use Doctrine\ORM\EntityRepository;

class LanguageRepository extends EntityRepository implements RepositoryInterface
{
    // --------

    /**
     * @return array
     */
    public function getAllLocale()
    {
        $queryBuilder = $this->createQueryBuilder('l');

        $queryBuilder->orderBy('l.orderBy','DESC');

        $query = $queryBuilder->getQuery();

        $query->useResultCache(true,60,md5('bacon_cache_locale_provider'));

        return $query->getResult();
    }

    // --------
}

The Versions

06/02 2016

dev-master

9999999-dev

This bundle of symfony2

  Sources   Download

MIT

by Adan Felipe Medeiros

form bundle