Last active
January 3, 2016 05:39
-
-
Save itxavia/8416920 to your computer and use it in GitHub Desktop.
Sonata Admin I18N Forms
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
services: | |
sonata.admin.ristorante: | |
class: Xavia\AdminBundle\Admin\RistoranteAdmin | |
tags: | |
- { name: sonata.admin, manager_type: orm, group: Amministrazione, label: "Ristorante" } | |
arguments: | |
- ~ | |
- Xavia\SitoBundle\Entity\Ristorante | |
- XaviaAdminBundle:Ristorante | |
calls: | |
- [ setTranslationDomain, [XaviaAdminBundle]] | |
sonata.admin.ambiente: | |
class: Xavia\AdminBundle\Admin\AmbienteAdmin | |
tags: | |
- { name: sonata.admin, manager_type: orm, group: Amministrazione, label: "Ambiente" } | |
arguments: | |
- ~ | |
- Xavia\SitoBundle\Entity\Ambiente | |
- XaviaAdminBundle:Ambiente | |
calls: | |
- [ setTranslationDomain, [XaviaAdminBundle]] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Xavia\SitoBundle\Entity; | |
use Doctrine\ORM\Mapping as ORM; | |
use Doctrine\Common\Collections\ArrayCollection; | |
use Gedmo\Mapping\Annotation as Gedmo; | |
use Gedmo\Translatable\Translatable; | |
/** | |
* Ambiente | |
* | |
* @ORM\Table(name="ambiente") | |
* @ORM\Entity | |
* @Gedmo\TranslationEntity(class="Xavia\SitoBundle\Entity\AmbienteTranslation") | |
*/ | |
class Ambiente | |
{ | |
/** | |
* @var integer | |
* | |
* @ORM\Column(name="id", type="integer", nullable = false) | |
* @ORM\Id | |
* @ORM\GeneratedValue(strategy="IDENTITY") | |
*/ | |
private $id; | |
/** | |
* @var string | |
* @Gedmo\Translatable | |
* @ORM\Column(name="ambiente", type="string", length=50, nullable = false) | |
*/ | |
private $ambiente; | |
/** | |
* @ORM\OneToMany(targetEntity="Ristorante", mappedBy="ambiente") | |
*/ | |
protected $ristorante; | |
/** | |
* @return string | |
*/ | |
public function __toString() | |
{ | |
return $this->ambiente; | |
} | |
/** | |
* @ORM\OneToMany(targetEntity="AmbienteTranslation", mappedBy="object", cascade={"persist", "remove"}) | |
*/ | |
protected $translations; | |
/** | |
* Required for Translatable behaviour | |
* @Gedmo\Locale | |
*/ | |
protected $locale; | |
/** | |
* Constructor | |
*/ | |
public function __construct() | |
{ | |
$this->ristorante = new \Doctrine\Common\Collections\ArrayCollection(); | |
$this->translations = new ArrayCollection(); | |
} | |
public function getLocale() | |
{ | |
return $this->locale; | |
} | |
public function setLocale($locale) | |
{ | |
$this->locale = $locale; | |
} | |
public function getTranslations() | |
{ | |
return $this->translations; | |
} | |
public function addTranslation(AmbienteTranslation $t) | |
{ | |
$this->translations->add($t); | |
$t->setObject($this); | |
} | |
public function removeTranslation(AmbienteTranslation $t) | |
{ | |
$this->translations->removeElement($t); | |
} | |
public function setTranslations($translations) | |
{ | |
$this->translations = $translations; | |
} | |
/** | |
* Get id | |
* | |
* @return integer | |
*/ | |
public function getId() | |
{ | |
return $this->id; | |
} | |
/** | |
* Set ambiente | |
* | |
* @param string $ambiente | |
* @return Ambiente | |
*/ | |
public function setAmbiente($ambiente) | |
{ | |
$this->ambiente = $ambiente; | |
return $this; | |
} | |
/** | |
* Get ambiente | |
* | |
* @return string | |
*/ | |
public function getAmbiente() | |
{ | |
return $this->ambiente; | |
} | |
/** | |
* Add ristorante | |
* | |
* @param \Xavia\SitoBundle\Entity\Ristorante $ristorante | |
* @return Ambiente | |
*/ | |
public function addRistorante(\Xavia\SitoBundle\Entity\Ristorante $ristorante) | |
{ | |
$this->ristorante[] = $ristorante; | |
return $this; | |
} | |
/** | |
* Remove ristorante | |
* | |
* @param \Xavia\SitoBundle\Entity\Ristorante $ristorante | |
*/ | |
public function removeRistorante(\Xavia\SitoBundle\Entity\Ristorante $ristorante) | |
{ | |
$this->ristorante->removeElement($ristorante); | |
} | |
/** | |
* Get ristorante | |
* | |
* @return \Doctrine\Common\Collections\Collection | |
*/ | |
public function getRistorante() | |
{ | |
return $this->ristorante; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Xavia\AdminBundle\Admin; | |
use Sonata\AdminBundle\Admin\Admin; | |
use Sonata\AdminBundle\Datagrid\ListMapper; | |
use Sonata\AdminBundle\Datagrid\DatagridMapper; | |
use Sonata\AdminBundle\Form\FormMapper; | |
class AmbienteAdmin extends Admin | |
{ | |
protected function configureFormFields(FormMapper $formMapper) | |
{ | |
$formMapper | |
->add('translations', 'a2lix_translations', array( | |
'by_reference' => false, | |
'locales' => array('it', 'en')) | |
); | |
/*$formMapper->add('translations', 'a2lix_translations');*/ | |
} | |
protected function configureDatagridFilters(DatagridMapper $datagridMapper) | |
{ | |
$datagridMapper | |
->add('ambiente') | |
; | |
} | |
protected function configureListFields(ListMapper $listMapper) | |
{ | |
$listMapper | |
->add('ambiente') | |
; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Xavia\SitoBundle\Entity; | |
use Doctrine\ORM\Mapping as ORM; | |
use Gedmo\Translatable\Entity\MappedSuperclass\AbstractPersonalTranslation; | |
/** | |
* @ORM\Entity | |
* @ORM\Table(name="ambiente_translations", | |
* uniqueConstraints={@ORM\UniqueConstraint(name="lookup_unique_idx", columns={ | |
* "locale", "object_id", "field" | |
* })} | |
* ) | |
*/ | |
class AmbienteTranslation extends AbstractPersonalTranslation | |
{ | |
/** | |
* Convinient constructor | |
* | |
* @param string $locale | |
* @param string $field | |
* @param string $content | |
*/ | |
public function __construct($locale = null, $field = null, $content = null) | |
{ | |
$this->setLocale($locale); | |
$this->setField($field); | |
$this->setContent($content); | |
} | |
/** | |
* @ORM\ManyToOne(targetEntity="Ambiente", inversedBy="translations") | |
* @ORM\JoinColumn(name="object_id", referencedColumnName="id", onDelete="CASCADE") | |
*/ | |
protected $object; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use Symfony\Component\HttpKernel\Kernel; | |
use Symfony\Component\Config\Loader\LoaderInterface; | |
class AppKernel extends Kernel | |
{ | |
public function registerBundles() | |
{ | |
$bundles = array( | |
new Symfony\Bundle\FrameworkBundle\FrameworkBundle(), | |
new Symfony\Bundle\SecurityBundle\SecurityBundle(), | |
new Symfony\Bundle\TwigBundle\TwigBundle(), | |
new Symfony\Bundle\MonologBundle\MonologBundle(), | |
new Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle(), | |
new Symfony\Bundle\AsseticBundle\AsseticBundle(), | |
new Doctrine\Bundle\DoctrineBundle\DoctrineBundle(), | |
new Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(), | |
new Xavia\SitoBundle\XaviaSitoBundle(), | |
new Sonata\CacheBundle\SonataCacheBundle(), | |
new Sonata\BlockBundle\SonataBlockBundle(), | |
new Knp\Bundle\MenuBundle\KnpMenuBundle(), | |
new Sonata\jQueryBundle\SonatajQueryBundle(), | |
new Sonata\CoreBundle\SonataCoreBundle(), | |
new Sonata\AdminBundle\SonataAdminBundle(), | |
new Vich\UploaderBundle\VichUploaderBundle(), | |
new Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle(), | |
new Stof\DoctrineExtensionsBundle\StofDoctrineExtensionsBundle(), | |
new FOS\UserBundle\FOSUserBundle(), | |
new Sonata\EasyExtendsBundle\SonataEasyExtendsBundle(), | |
new Sonata\UserBundle\SonataUserBundle('FOSUserBundle'), | |
new Sonata\DoctrineORMAdminBundle\SonataDoctrineORMAdminBundle(), | |
new Application\Sonata\UserBundle\ApplicationSonataUserBundle(), | |
new Craue\FormFlowBundle\CraueFormFlowBundle(), | |
new Sonata\IntlBundle\SonataIntlBundle(), | |
new Xavia\AdminBundle\XaviaAdminBundle(), | |
new Stfalcon\Bundle\TinymceBundle\StfalconTinymceBundle(), | |
new A2lix\TranslationFormBundle\A2lixTranslationFormBundle(), | |
); | |
if (in_array($this->getEnvironment(), array('dev', 'test'))) { | |
$bundles[] = new Symfony\Bundle\WebProfilerBundle\WebProfilerBundle(); | |
$bundles[] = new Sensio\Bundle\DistributionBundle\SensioDistributionBundle(); | |
$bundles[] = new Sensio\Bundle\GeneratorBundle\SensioGeneratorBundle(); | |
} | |
return $bundles; | |
} | |
public function registerContainerConfiguration(LoaderInterface $loader) | |
{ | |
$loader->load(__DIR__.'/config/config_'.$this->getEnvironment().'.yml'); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "symfony/framework-standard-edition", | |
"license": "MIT", | |
"type": "project", | |
"description": "The \"Symfony Standard Edition\" distribution", | |
"autoload": { | |
"psr-0": { "": "src/" } | |
}, | |
"require": { | |
"php": ">=5.3.3", | |
"symfony/symfony": "2.3.*", | |
"symfony/assetic-bundle": "2.3.*", | |
"symfony/swiftmailer-bundle": "2.3.*", | |
"symfony/monolog-bundle": "2.3.*", | |
"doctrine/orm": ">=2.2.3,<2.4-dev", | |
"doctrine/doctrine-bundle": "1.2.*", | |
"doctrine/data-fixtures": "dev-master", | |
"doctrine/doctrine-fixtures-bundle": "dev-master", | |
"twig/extensions": "1.0.*", | |
"sensio/distribution-bundle": "2.3.*", | |
"sensio/framework-extra-bundle": "2.3.*", | |
"sensio/generator-bundle": "2.3.*", | |
"sonata-project/core-bundle": "dev-master", | |
"sonata-project/admin-bundle": "2.*", | |
"sonata-project/doctrine-orm-admin-bundle": "2.2.*", | |
"sonata-project/cache-bundle": "2.1.*", | |
"sonata-project/block-bundle": "2.2.*", | |
"sonata-project/jquery-bundle": "1.8.*", | |
"sonata-project/exporter": "1.*", | |
"sonata-project/easy-extends-bundle": "2.1.*", | |
"sonata-project/user-bundle": "2.2.*@dev", | |
"sonata-project/intl-bundle": "2.1.*", | |
"knplabs/knp-menu-bundle":"1.1.*", | |
"incenteev/composer-parameter-handler": "~2.0", | |
"vich/uploader-bundle": "dev-master", | |
"stof/doctrine-extensions-bundle": "~1.1@dev", | |
"craue/formflow-bundle": "~2.0.0", | |
"stfalcon/tinymce-bundle": "dev-master", | |
"a2lix/translation-form-bundle": "dev-master", | |
"pugx/generator-bundle": "dev-master", | |
"knplabs/knp-paginator-bundle": "2.3.*", | |
"lexik/form-filter-bundle": "1.2.*" | |
}, | |
"scripts": { | |
"post-install-cmd": [ | |
"Incenteev\\ParameterHandler\\ScriptHandler::buildParameters", | |
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap", | |
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache", | |
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets", | |
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile" | |
], | |
"post-update-cmd": [ | |
"Incenteev\\ParameterHandler\\ScriptHandler::buildParameters", | |
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap", | |
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache", | |
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets", | |
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile" | |
] | |
}, | |
"config": { | |
"bin-dir": "bin" | |
}, | |
"minimum-stability": "stable", | |
"extra": { | |
"symfony-app-dir": "app", | |
"symfony-web-dir": "web", | |
"incenteev-parameters": { | |
"file": "app/config/parameters.yml" | |
}, | |
"branch-alias": { | |
"dev-master": "2.3-dev" | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
http://i44.tinypic.com/291golk.jpg |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment