Author: Adam Piotrowski (adam@wellcommerce.org)
Inheritance: extends WellCommerce\Bundle\DoctrineBundle\Repository\RepositoryInterface
Example #1
0
 /**
  * {@inheritdoc}
  */
 public function getAvailableLocales()
 {
     if (null === $this->locales) {
         $this->locales = $this->repository->getAvailableLocales();
     }
     return $this->locales;
 }
Example #2
0
 /**
  * {@inheritdoc}
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $form = $builder->init($options);
     $requiredData = $form->addChild($builder->getElement('fieldset', ['name' => 'required_data', 'label' => $this->trans('form.required_data')]));
     $requiredData->addChild($builder->getElement('select', ['name' => 'code', 'label' => $this->trans('locale.code'), 'options' => $this->repository->getLocaleNames()]));
     $form->addFilter('no_code');
     $form->addFilter('trim');
     $form->addFilter('secure');
     return $form;
 }
 /**
  * @return array
  */
 protected function getSourceLocales()
 {
     $locales = [];
     $collection = $this->localeRepository->matching(new Criteria());
     $collection->map(function (LocaleInterface $locale) use(&$locales) {
         $locales[$locale->getCode()] = $locale->getCode();
     });
     return $locales;
 }
 /**
  * Constructor
  *
  * @param LocaleRepositoryInterface $repository
  */
 public function __construct(LocaleRepositoryInterface $repository)
 {
     $this->repository = $repository;
     $this->options['languages'] = $repository->getAvailableLocales();
     parent::__construct($this->options);
 }