Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[OptionsResolver] Add new OptionConfigurator class to define options with fluent interface #33848

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

Merged
merged 1 commit into from
Feb 6, 2020

Conversation

lmillucci
Copy link
Contributor

@lmillucci lmillucci commented Oct 4, 2019

Q A
Branch? master
Bug fix? no
New feature? yes
Deprecations? no
Tickets Fix #33735
License MIT
Doc PR symfony/symfony-docs#12426
  • submit changes to the documentation

This PR adds OptionConfigurator to the OptionsResolver

Copy link
Member

@yceruto yceruto left a comment

Choose a reason for hiding this comment

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

Thanks @lmillucci for working on this feature :) I like it ! and congratulation for your first pull request.

I've left some comments to move as fast as we can, thanks again.

@yceruto yceruto added this to the next milestone Oct 4, 2019
@ro0NL
Copy link
Contributor

ro0NL commented Oct 4, 2019

something else we may want to consider, and what we did for DI configurators as well, is to make it truly fluid;

$optionsResolver
    ->define('foo')
        ->required()
    ->define('bar')
        ->required()
;

Copy link
Member

@yceruto yceruto left a comment

Choose a reason for hiding this comment

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

With minor comments.

@yceruto
Copy link
Member

yceruto commented Oct 7, 2019

@lmillucci thanks for your work and for solving all comments.

After the discussion we had about this #33848 (comment) where I suggest you to remove the annotation @return $this, I think we should add it again now, because it should help make it clear that it is a fluent interface by saying that each method will return the same instance of the class $this, except for the define() method that will return a new instance.

I'm sorry about that, and I hope you're okay.

@lmillucci
Copy link
Contributor Author

@yceruto no problem, I've easily restored @return $this annotation for all methods except define()

@yceruto yceruto changed the title [OptionsResolver] add OptionConfigurator Issue #33735 [OptionsResolver] Add new OptionConfigurator class to define options with fluent interface Oct 9, 2019
@yceruto
Copy link
Member

yceruto commented Oct 9, 2019

@stof could you please review this PR again and have your vote on this ? thanks!

@yceruto
Copy link
Member

yceruto commented Oct 15, 2019

ping @symfony/mergers ?

src/Symfony/Component/OptionsResolver/OptionsResolver.php Outdated Show resolved Hide resolved
src/Symfony/Component/OptionsResolver/OptionsResolver.php Outdated Show resolved Hide resolved
src/Symfony/Component/OptionsResolver/OptionsResolver.php Outdated Show resolved Hide resolved
@yceruto
Copy link
Member

yceruto commented Oct 21, 2019

Ready for final reviews (the fabbot.io failure is a false positive)

@yceruto
Copy link
Member

yceruto commented Jan 18, 2020

@lmillucci do you like to finish this proposal?

@lmillucci
Copy link
Contributor Author

lmillucci commented Jan 20, 2020

@lmillucci do you like to finish this proposal?

@yceruto Yes, what exception should be thrown when defining an already defined option? Something like OptionDefinitionException should be ok?

@yceruto
Copy link
Member

yceruto commented Jan 20, 2020

@lmillucci yes, OptionDefinitionException would be ok.

@yceruto
Copy link
Member

yceruto commented Jan 21, 2020

@lmillucci almost done :) you just need to rebase on master branch to make it ready for Symfony 5.1

@lmillucci lmillucci force-pushed the 33735-option-resolver branch from 1369e55 to e5f8397 Compare January 21, 2020 16:05
@lmillucci lmillucci force-pushed the 33735-option-resolver branch from e5f8397 to 519acba Compare January 21, 2020 16:27
@yceruto yceruto changed the base branch from 4.4 to master January 21, 2020 19:54
@yceruto
Copy link
Member

yceruto commented Jan 21, 2020

there is a commit that don't belongs to this PR f825642 (the first one) could you please, fix it? thanks!

@lmillucci lmillucci force-pushed the 33735-option-resolver branch from 519acba to 789dcfd Compare January 22, 2020 08:30
@chalasr
Copy link
Member

chalasr commented Jan 27, 2020

The component's CHANGELOG file should mention this change.

@nicolas-grekas
Copy link
Member

Thank you @lmillucci.

nicolas-grekas added a commit that referenced this pull request Feb 6, 2020
…define options with fluent interface (lmillucci, yceruto)

This PR was merged into the 5.1-dev branch.

Discussion
----------

[OptionsResolver] Add new OptionConfigurator class to define options with fluent interface

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | yes
| Deprecations? | no
| Tickets       | Fix #33735
| License       | MIT
| Doc PR        |  symfony/symfony-docs#12426

- [x] submit changes to the documentation

This PR adds OptionConfigurator to the OptionsResolver

Commits
-------

1ff5640 [OptionsResolver] Add new OptionConfigurator class to define options with fluent interface
@nicolas-grekas nicolas-grekas merged commit 1ff5640 into symfony:master Feb 6, 2020
OskarStark added a commit to symfony/symfony-docs that referenced this pull request Feb 19, 2020
…lucci)

This PR was squashed before being merged into the master branch.

Discussion
----------

[OptionResolver] Document the OptionConfigurator

Add `define()` method to OptionResolver to enhance readability of option configuration. See  symfony/symfony#33848

Commits
-------

921c73f [OptionResolver] Document the OptionConfigurator
@nicolas-grekas nicolas-grekas modified the milestones: next, 5.1 May 4, 2020
@fabpot fabpot mentioned this pull request May 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add OptionsResolver::configureOptions()
10 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.