Skip to content

Commit

Permalink
Fix root node deprecations (#328)
Browse files Browse the repository at this point in the history
* Fix root node deprecations

* Update travis

* fix lint errors
  • Loading branch information
jordisala1991 authored Mar 4, 2019
1 parent 13ee5bf commit c0290ac
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 21 deletions.
25 changes: 13 additions & 12 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ php:
- '7.0'
- '7.1'
- '7.2'
- '7.3'
- nightly

sudo: false
Expand All @@ -29,28 +30,28 @@ env:
matrix:
fast_finish: true
include:
- php: '5.4'
- php: '5.6'
env: COMPOSER_FLAGS="--prefer-lowest"
- php: '7.0'
env: SYMFONY=2.3.*
- php: '7.2'
- php: '7.0'
env: SYMFONY=2.7.*
- php: '7.2'
- php: '7.0'
env: SYMFONY=2.8.*
- php: '7.2'
env: SYMFONY=3.3.*
- php: '7.2'
- php: '7.3'
env: SYMFONY=3.4.*
- php: '7.2'
env: SYMFONY=4.0.*
- php: '7.2'
env: SYMFONY='dev-master as 4.1.x-dev'
- php: '7.2'
- php: '7.3'
env: SYMFONY=4.1.*
- php: '7.3'
env: SYMFONY=4.2.*
- php: '7.3'
env: SYMFONY='dev-master as 4.3.x-dev'
- php: '7.3'
env: SYMFONY_DEPRECATIONS_HELPER=0
allow_failures:
- php: nightly
- env: SYMFONY_DEPRECATIONS_HELPER=0
- env: SYMFONY='dev-master as 4.1.x-dev'
- env: SYMFONY='dev-master as 4.3.x-dev'

before_install:
- echo memory_limit = -1 >> $HOME/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini;
Expand Down
2 changes: 1 addition & 1 deletion DependencyInjection/Compiler/TemplatingPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function process(ContainerBuilder $container)
if (false !== ($template = $container->getParameter('a2lix_translation_form.templating'))) {
$resources = $container->getParameter('twig.form.resources');

if (!in_array($template, $resources)) {
if (!\in_array($template, $resources)) {
$resources[] = $template;
$container->setParameter('twig.form.resources', $resources);
}
Expand Down
10 changes: 8 additions & 2 deletions DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,14 @@ class Configuration implements ConfigurationInterface
*/
public function getConfigTreeBuilder()
{
$treeBuilder = new TreeBuilder();
$rootNode = $treeBuilder->root('a2lix_translation_form');
$treeBuilder = new TreeBuilder('a2lix_translation_form');

// Keep compatibility with symfony/config < 4.2
if (!method_exists($treeBuilder, 'getRootNode')) {
$rootNode = $treeBuilder->root('a2lix_translation_form');
} else {
$rootNode = $treeBuilder->getRootNode();
}

$rootNode
->children()
Expand Down
2 changes: 1 addition & 1 deletion Form/EventListener/TranslationsListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public function preSetData(FormEvent $event)
[
'data_class' => $translationClass,
'fields' => $fieldsOptions[$locale],
'required' => in_array($locale, $formOptions['required_locales']),
'required' => \in_array($locale, $formOptions['required_locales']),
]
);
}
Expand Down
2 changes: 1 addition & 1 deletion Form/Type/TranslatedEntityType.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public function configureOptions(OptionsResolver $resolver)
{
// BC for SF < 2.7
$optionProperty = 'choice_label';
if (in_array('property', $resolver->getDefinedOptions())) {
if (\in_array('property', $resolver->getDefinedOptions())) {
$optionProperty = 'property';
}

Expand Down
2 changes: 1 addition & 1 deletion Form/Type/TranslationsFormsType.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public function buildForm(FormBuilderInterface $builder, array $options)
foreach ($options['locales'] as $locale) {
if (isset($formsOptions[$locale])) {
$builder->add($locale, $options['form_type'],
$formsOptions[$locale] + ['required' => in_array($locale, $options['required_locales'])]
$formsOptions[$locale] + ['required' => \in_array($locale, $options['required_locales'])]
);
}
}
Expand Down
4 changes: 2 additions & 2 deletions Locale/DefaultProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ class DefaultProvider implements LocaleProviderInterface
*/
public function __construct(array $locales, $defaultLocale, array $requiredLocales = [])
{
if (!in_array($defaultLocale, $locales)) {
if (count($locales) > 0) {
if (!\in_array($defaultLocale, $locales)) {
if (\count($locales) > 0) {
throw new \InvalidArgumentException(sprintf('Default locale `%s` not found within the configured locales `[%s]`. Perhaps you need to add it to your `a2lix_translation_form.locales` bundle configuration?', $defaultLocale, implode(',', $locales)));
}

Expand Down
2 changes: 1 addition & 1 deletion TranslationForm/TranslationForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ protected function getTranslationFields($translationClass, array $exclude = [])
$metadataClass = $manager->getMetadataFactory()->getMetadataFor($translationClass);

foreach ($metadataClass->fieldMappings as $fieldMapping) {
if (!in_array($fieldMapping['fieldName'], ['id', 'locale']) && !in_array($fieldMapping['fieldName'], $exclude)) {
if (!\in_array($fieldMapping['fieldName'], ['id', 'locale']) && !\in_array($fieldMapping['fieldName'], $exclude)) {
$fields[] = $fieldMapping['fieldName'];
}
}
Expand Down

0 comments on commit c0290ac

Please sign in to comment.