/** * {@inheritdoc} */ public function buildForm(FormBuilderInterface $builder, array $options) { $builder->add('name', 'text', ['label' => 'orob2b.rfp.requeststatus.name.label', 'required' => true])->add('sortOrder', 'integer', ['label' => 'orob2b.rfp.requeststatus.sort_order.label', 'required' => true]); $lang = $this->localeSettings->getLanguage(); $notificationLangs = $this->userConfig->get('oro_locale.languages'); $notificationLangs = array_unique(array_merge($notificationLangs, [$lang])); $localeLabels = $this->localeSettings->getLocalesByCodes($notificationLangs, $lang); $builder->add('translations', 'orob2b_rfp_request_status_translation', ['label' => 'orob2b.rfp.requeststatus.label.label', 'required' => false, 'locales' => $notificationLangs, 'labels' => $localeLabels]); }
public function testGetLocaleByCode() { $locales = $this->localeSettings->getLocalesByCodes(['en', 'fr']); $this->assertCount(2, $locales); $this->configManager->expects($this->once())->method('get')->with('test'); $this->localeSettings->get('test'); }
/** * Gets translated locale name by its code * * @param string|null $locale The locale code. NULL means default locale * * @return string */ protected function getLocaleName($locale) { $currentLang = $this->localeSettings->getLanguage(); if (empty($locale)) { $locale = $currentLang; } $localeNames = $this->localeSettings->getLocalesByCodes([$locale], $currentLang); return $localeNames[$locale]; }
/** * {@inheritdoc} */ public function buildForm(FormBuilderInterface $builder, array $options) { $builder->add('name', 'text', array('label' => 'oro.email.emailtemplate.name.label', 'required' => true)); $builder->add('type', 'choice', array('label' => 'oro.email.emailtemplate.type.label', 'multiple' => false, 'expanded' => true, 'choices' => array('html' => 'oro.email.datagrid.emailtemplate.filter.type.html', 'txt' => 'oro.email.datagrid.emailtemplate.filter.type.txt'), 'required' => true)); $builder->add('entityName', 'oro_entity_choice', array('label' => 'oro.email.emailtemplate.entity_name.label', 'tooltip' => 'oro.email.emailtemplate.entity_name.tooltip', 'required' => false, 'configs' => ['allowClear' => true])); $lang = $this->localeSettings->getLanguage(); $notificationLangs = $this->userConfig->get('oro_locale.languages'); $notificationLangs = array_merge($notificationLangs, [$lang]); $localeLabels = $this->localeSettings->getLocalesByCodes($notificationLangs, $lang); $builder->add('translations', 'oro_email_emailtemplate_translatation', array('label' => 'oro.email.emailtemplate.translations.label', 'required' => false, 'locales' => $notificationLangs, 'labels' => $localeLabels)); $builder->add('parentTemplate', 'hidden', array('label' => 'oro.email.emailtemplate.parent.label', 'property_path' => 'parent')); // disable some fields for non editable email template $setDisabled = function (&$options) { if (isset($options['auto_initialize'])) { $options['auto_initialize'] = false; } $options['disabled'] = true; }; $factory = $builder->getFormFactory(); $builder->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) use($factory, $setDisabled) { $data = $event->getData(); if ($data && $data->getId() && $data->getIsSystem()) { $form = $event->getForm(); // entityName field $options = $form->get('entityName')->getConfig()->getOptions(); $setDisabled($options); $form->add($factory->createNamed('entityName', 'oro_entity_choice', null, $options)); // name field $options = $form->get('name')->getConfig()->getOptions(); $setDisabled($options); $form->add($factory->createNamed('name', 'text', null, $options)); if (!$data->getIsEditable()) { // name field $options = $form->get('type')->getConfig()->getOptions(); $setDisabled($options); $form->add($factory->createNamed('type', 'choice', null, $options)); } } }); }
/** * @return array */ protected function getLocaleLabels() { return $this->localeSettings->getLocalesByCodes($this->getLanguages(), $this->localeSettings->getLanguage()); }