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

[Config] Add ExprBuilder::ifEmpty() #6922

Merged

Conversation

ogizanagi
Copy link
Contributor

@wouterj
Copy link
Member

wouterj commented Aug 28, 2016

Can you please add (since Symfony 3.2) after the list item?

@ogizanagi ogizanagi force-pushed the feature/3.2/config/if_empty_expr_builder branch from 7ef398d to f0fe739 Compare August 28, 2016 16:54
@ogizanagi
Copy link
Contributor Author

@wouterj : Added :)

fabpot added a commit to symfony/symfony that referenced this pull request Aug 31, 2016
This PR was merged into the 3.2-dev branch.

Discussion
----------

[Config] Add ExprBuilder::ifEmpty()

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets |
| License       | MIT
| Doc PR        | symfony/symfony-docs#6922

Useful for instance when you don't expect to have a key set in the resolved config if its content is empty:

```php
$builder = new TreeBuilder();
$tree = $builder
    ->root('matcher')
        ->children()
            ->arrayNode('references_to_exclude')
                ->validate()
                    ->ifEmpty()
                    ->thenUnset()
                ->end()
                ->prototype('scalar')->end()
            ->end()
        ->end()
    ->end()
    ->buildTree()
;

$tree->finalize(['references_to_exclude' => ['foo', 'bar']]);
>>> ['references_to_exclude' => ['foo', 'bar']]

$tree->finalize(['references_to_exclude' => []]);
>>> []
```

Commits
-------

4e46f64 [Config] Add ExprBuilder::ifEmpty()
symfony-splitter pushed a commit to symfony/config that referenced this pull request Aug 31, 2016
This PR was merged into the 3.2-dev branch.

Discussion
----------

[Config] Add ExprBuilder::ifEmpty()

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets |
| License       | MIT
| Doc PR        | symfony/symfony-docs#6922

Useful for instance when you don't expect to have a key set in the resolved config if its content is empty:

```php
$builder = new TreeBuilder();
$tree = $builder
    ->root('matcher')
        ->children()
            ->arrayNode('references_to_exclude')
                ->validate()
                    ->ifEmpty()
                    ->thenUnset()
                ->end()
                ->prototype('scalar')->end()
            ->end()
        ->end()
    ->end()
    ->buildTree()
;

$tree->finalize(['references_to_exclude' => ['foo', 'bar']]);
>>> ['references_to_exclude' => ['foo', 'bar']]

$tree->finalize(['references_to_exclude' => []]);
>>> []
```

Commits
-------

4e46f64 [Config] Add ExprBuilder::ifEmpty()
@ogizanagi ogizanagi changed the title [WCM][Config] Add ExprBuilder::ifEmpty() [Config] Add ExprBuilder::ifEmpty() Aug 31, 2016
@ogizanagi
Copy link
Contributor Author

Code repository PR is now merged :)

@wouterj wouterj removed the On hold label Aug 31, 2016
@wouterj
Copy link
Member

wouterj commented Aug 31, 2016

Cool! Let's merge this one as well then.

👍
status: review

@weaverryan
Copy link
Member

Awesome, thanks Maxime!

@weaverryan weaverryan merged commit f0fe739 into symfony:master Sep 18, 2016
weaverryan added a commit that referenced this pull request Sep 18, 2016
This PR was merged into the master branch.

Discussion
----------

[Config] Add ExprBuilder::ifEmpty()

After symfony/symfony#19764

Commits
-------

f0fe739 [WCM][Config] Add ExprBuilder::ifEmpty()
@ogizanagi ogizanagi deleted the feature/3.2/config/if_empty_expr_builder branch September 19, 2016 06:32
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.

4 participants