Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add symfony 3.0 support #752

Merged
merged 3 commits into from
Dec 4, 2015
Merged

Add symfony 3.0 support #752

merged 3 commits into from
Dec 4, 2015

Conversation

GuilhemN
Copy link
Collaborator

This PR adds symfony 3.0 support.

"type": "vcs",
"url": "https://github.com/Ener-Getick/DunglasApiBundle.git"
}
],
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Must be removed once api-platform/core#323 is merged.

@GuilhemN
Copy link
Collaborator Author

ping @willdurand

@weaverryan
Copy link

@Ener-Getick This is GREAT work, but your tests are failing:

Could you take a look at the tests please?

Thanks!

@GuilhemN
Copy link
Collaborator Author

I will try to fix the remaining deprecations tomorrow, I didn't localize all of them yet.

@GuilhemN
Copy link
Collaborator Author

@xabbuh @fabpot do you know why there is no stable release of symfony/form on packagist ?

@xabbuh
Copy link

xabbuh commented Nov 28, 2015

Not sure what you mean. I see lots of stable versions.

@GuilhemN
Copy link
Collaborator Author

Apparently this is fixed. A few minutes ago there were only the dev versions available.

@GuilhemN
Copy link
Collaborator Author

I fixed several errors but the behavior of the symfony forms seems to be changed in sf 3.0 and so the NelmioApiDocBundle behavior ... :/

@GuilhemN GuilhemN closed this Nov 30, 2015
@weaverryan
Copy link

@Ener-Getick why did you close this? We can find a solution for supporting the form behavior across multiple versions - SonataAdminBundle also had to support this problem. I would love for you to continue your nice work to completion!

@GuilhemN GuilhemN deleted the SF3 branch November 30, 2015 15:02
@GuilhemN GuilhemN restored the SF3 branch November 30, 2015 15:02
@GuilhemN GuilhemN reopened this Nov 30, 2015
@GuilhemN
Copy link
Collaborator Author

I didn't have any response so I thought you abandon. I'm not really involved in symfony core and in symfony/form so I don't know how we can fix this and why this behavior changed :-/

@xabbuh
Copy link

xabbuh commented Nov 30, 2015

I'll try to help you with this after SymfonyCon (I.e. next week). Please ping me then if I forget about it.

@weaverryan
Copy link

👍 @xabbuh

And @Ener-Getick what are the problems that you're seeing? I noticed that you have the LegacyFormHelper, which is a nice way to handle the text -> TextType style of changes.

@GuilhemN
Copy link
Collaborator Author

Thanks @xabbuh :-)

@weaverryan the output of the formatters has changed (an example) I don't know why... I'll try to search again this week.

But I'm wondering if it wouldn't be easier to split this PR because it introduces a lot of changes to test at the same time...

@weaverryan
Copy link

Hmm, yea, I don't know about the formatting change - that is strange.

If it's easier for you to split across multiple PR's and get things working, you could do that. But I don't think it's too hard for a reviewer to review.

@GuilhemN
Copy link
Collaborator Author

The problem is that I've made too many changes and I don't know when failures appeared... I'll create a new PR for everything already stable.

Finally, I'll just revert the last changes of this PR to found when errors appeared. No need of a new PR ^^

@GuilhemN
Copy link
Collaborator Author

There are already several errors with symfony 2.8 (see the build). I'll try to understand why this tests fail.

->add('c1', $choiceType, array('choices' => array('m' => 'Male', 'f' => 'Female'), 'choices_as_values' => true))
->add('c2', $choiceType, array('choices' => array('m' => 'Male', 'f' => 'Female'), 'choices_as_values' => true, 'multiple' => true))
->add('c3', $choiceType, array('choices' => array()))
->add('c4', $choiceType, array('choices' => array('foo' => 'bar', 'bazgroup' => array('baz' => 'Buzz')), 'choices_as_values' => true))
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The users will have to update their form with choices_as_values if they want to use symfony 2.8 :/

@willdurand willdurand added WIP Work in progress issues that are not ready for implementation accepted labels Dec 1, 2015
@willdurand willdurand added this to the 2.12.0 milestone Dec 1, 2015
@GuilhemN
Copy link
Collaborator Author

GuilhemN commented Dec 1, 2015

The last commit speeds up travis of ~50% !
before / after

@GuilhemN
Copy link
Collaborator Author

GuilhemN commented Dec 1, 2015

The remaining errors seem unrelated to this PR. Needs review

@GuilhemN GuilhemN changed the title [WIP] Add symfony 3.0 support Add symfony 3.0 support Dec 1, 2015
} else {
throw new \InvalidArgumentException('Unsupported form type class.');
}
}

$name = array_key_exists('name', $item) ? $item['name'] : $form->getName();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Form::getName has been removed from Symfony 3, use getBlockPrefix instead

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, this line is apparently not covered by the tests...

@weaverryan
Copy link

The asset() function failure on 3.0 should be fixed by adding asset: ~ into default.yml under the framework key: https://github.com/nelmio/NelmioApiDocBundle/blob/master/Tests/Fixtures/app/config/default.yml

But, that will also break the tests in 2.7 and lower. So in practice, we may need to add it in AppKernel, detect the Symfony version, and only add the asset key (this can be done via a closure) for 2.8 and higher.

Nice job btw!

@GuilhemN
Copy link
Collaborator Author

GuilhemN commented Dec 3, 2015

You're welcome ;-)

And yeah, see this. Can you relaunch Travis? Otherwise I'll do it tonight.

@willdurand
Copy link
Collaborator

@Ener-Getick that's what I did (triggering travis-ci again), but it is still failing...

@GuilhemN
Copy link
Collaborator Author

GuilhemN commented Dec 3, 2015

Yeah just see that dunglas/api-bundle is under 2.0.x-dev

@willdurand
Copy link
Collaborator

oh yes... @dunglas can we safely rely on 2.0@dev?

@dunglas
Copy link
Contributor

dunglas commented Dec 3, 2015

No we can't but AFAIK the @Ener-Getick patch (thx for the good work) has been merged in 1.0@dev.

@GuilhemN
Copy link
Collaborator Author

GuilhemN commented Dec 3, 2015

I just discovered that packagist detects the branches named \d.\d the problem is that the last dev release is v1.1.0-beta.1 and 1.0@dev < v1.1.0-beta.1.

@dunglas could you rename your branch to 1.1 ?

@dunglas
Copy link
Contributor

dunglas commented Dec 4, 2015

I've just created a 1.1 branch (it's cleaner I think). It should work when #764 is merged.

@dunglas
Copy link
Contributor

dunglas commented Dec 4, 2015

In fact renaming the 1.0 branch to 1.x do the trick. Can you run Travis again?

@GuilhemN
Copy link
Collaborator Author

GuilhemN commented Dec 4, 2015

It works thanks @dunglas

willdurand added a commit that referenced this pull request Dec 4, 2015
@willdurand willdurand merged commit 1df3ddf into nelmio:master Dec 4, 2015
@willdurand
Copy link
Collaborator

awesome, thanks!

@dunglas
Copy link
Contributor

dunglas commented Dec 4, 2015

Thanks a lot @Ener-Getick

@rande
Copy link

rande commented Dec 4, 2015

GG!

@luispabon
Copy link

Thank you 👍

1 Neal Street London WC2H 9QL

www.rightster.com | @Rightster https://twitter.com/rightster | LinkedIn
https://www.linkedin.com/company/rightster

Rightster Limited (incorporated in England with company number 07634543)
has its registered office at 1 Neal Street London WC2H 9QL. Rightster
Limited is a subsidiary of Rightster Group plc (incorporated in England and
Wales with company number 08754680).

@GuilhemN GuilhemN deleted the SF3 branch December 4, 2015 16:45
@GuilhemN
Copy link
Collaborator Author

GuilhemN commented Dec 4, 2015

Awesome thank you all for your help

@teohhanhui
Copy link
Contributor

I get this deprecation notice on Symfony 2.8:

The alias option of the form.type_extension tag is deprecated since version 2.8 and will be removed in 3.0. Use the extended_type option instead.

This is because of the "alias" attribute here:

<tag name="form.type_extension" alias="form" extended-type="Symfony\Component\Form\Extension\Core\Type\FormType" />

@GuilhemN
Copy link
Collaborator Author

GuilhemN commented Dec 8, 2015

Hum this deprecation has probably been added later. I'll fix it this afternoon.

@GuilhemN
Copy link
Collaborator Author

GuilhemN commented Dec 8, 2015

Which version of the bundle do you use ? This should not trigger a deprecation see here

@teohhanhui
Copy link
Contributor

@Ener-Getick You're right. It must be caused by another bundle then... (The way deprecation warnings are logged is pretty unhelpful.)

@weaverryan
Copy link

@teohhanhui you can open an issue in symfony/symfony if a deprecation warning isn't clear enough - it's pretty common that many can be improved to contain more information (in this case, if the service id were in the message, that would help a lot).

@willdurand
Copy link
Collaborator

@teohhanhui v2.11.1 is released and contains @Ener-Getick's fix.

@GuilhemN
Copy link
Collaborator Author

GuilhemN commented Dec 8, 2015

I forgot to specify, it's a fix for a deprecation triggered in the tests not in production :x

@willdurand
Copy link
Collaborator

@Ener-Getick yep, but it documents how to fix this deprecation :)

@teohhanhui
Copy link
Contributor

Uhh, yes. I rechecked and it turns out I was using 2.10.3. The deprecation notice I was getting was already fixed by this PR (in 2.11.0). Silly me!

@OskarStark
Copy link
Contributor

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
WIP Work in progress issues that are not ready for implementation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

9 participants