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

[Twig][Form] Moved twig.form.resources to a higher level #11343

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
Sep 15, 2014

Conversation

stefanosala
Copy link

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

@@ -55,7 +55,12 @@ public function load(array $configs, ContainerBuilder $container)

$container->setParameter('twig.exception_listener.controller', $config['exception_controller']);

$container->setParameter('twig.form.resources', $config['form']['resources']);
// To prevent BC, load the configuration from both branches
$formThemes = array_unique(array_merge($config['form']['resources'], $config['form_themes']));
Copy link
Member

Choose a reason for hiding this comment

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

This should be handled in the Configuration class instead, by rewriting the old path to the new one

Copy link
Author

Choose a reason for hiding this comment

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

Hints on how to do that?

Copy link
Contributor

Choose a reason for hiding this comment

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

You can add a normalizer (on the $rootNode) which checks if ['form']['resources'] is set, and call a closure which merges the configurations into form_theme.

->beforeNormalization()
    ->ifTrue(function ($v) { return count($value['form']['resources']) > 0; })
    ->then(function($v) {
        $v['form_themes'] = array_unique(array_merge($v['form']['resources'], $v['form_themes']));

        return $v;
    })
->end()

Copy link
Author

Choose a reason for hiding this comment

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

Thanks for the hint, I just had to do that in validate() method because it has to happen after xml normalization.

@egeloen
Copy link

egeloen commented Jul 7, 2014

Not sure if this PR is fully BC. Does it will still support to merge extra resources in a DI extension as done here?

@stefanosala
Copy link
Author

@egeloen No, you're right, it doesn't support the merge of extra resources at the moment.
Maybe we can keep the parameter name twig.form.resources instead of using the new one (twig.form_themes) even if it matches with the config array structure.
What do you think?

@stof
Copy link
Member

stof commented Jul 7, 2014

the name of the DIC parameter should indeed be preserved

@stefanosala
Copy link
Author

Fixed. 👍

@stefanosala
Copy link
Author

Doc PR created.

@weaverryan
Copy link
Member

@stefanosala There is a slight code standards issue - check out fabbot on the link near the bottom.

And awesome job!

@stefanosala
Copy link
Author

@weaverryan 👍 thank you for the review!

@fabpot
Copy link
Member

fabpot commented Aug 28, 2014

👍

@@ -31,6 +31,8 @@ public function testLoadEmptyConfiguration()
$this->compileContainer($container);

$this->assertEquals('Twig_Environment', $container->getParameter('twig.class'), '->load() loads the twig.xml file');

// @deprecated since 2.6, to be removed in 3.0
Copy link
Member

Choose a reason for hiding this comment

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

this is wrong. The DIC parameter is not deprecated

Copy link
Author

Choose a reason for hiding this comment

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

it took me a while to understand why, but you're right, merci!

@stefanosala stefanosala force-pushed the feature/move-form-theme branch from c3e6060 to ab0b5e6 Compare August 29, 2014 06:02
@webmozart
Copy link
Contributor

Thanks Stefano for working on this feature, this is much appreciated.

@webmozart webmozart merged commit ab0b5e6 into symfony:master Sep 15, 2014
webmozart added a commit that referenced this pull request Sep 15, 2014
…el (stefanosala)

This PR was merged into the 2.6-dev branch.

Discussion
----------

[Twig][Form] Moved twig.form.resources to a higher level

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

Commits
-------

ab0b5e6 [Twig][Form] Moved configuration key twig.form.resources to twig.form_themes
@stefanosala stefanosala deleted the feature/move-form-theme branch September 15, 2014 18:23
weaverryan added a commit to symfony/symfony-docs that referenced this pull request Sep 24, 2014
…l (stefanosala)

This PR was merged into the master branch.

Discussion
----------

[Twig][Form] Moved twig.form.resources to a higher level

| Q             | A
| ------------- | ---
| Doc fix?      | no
| New docs?     | no, symfony/symfony#11343
| Applies to    | >= 2.6
| Fixed tickets | -

Commits
-------

63d8657 [Twig][Form] Moved twig.form.resources to a higher level
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.

8 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.