Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

[FrameworkBundle] Added configuration for additionnal request formats#8944

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Closed
gquemener wants to merge11 commits intosymfony:masterfromgquemener:master
Closed

Conversation

gquemener
Copy link
Contributor

QA
Bug fix?no
New feature?yes
BC breaks?no
Deprecations?no
Tests pass?no
Fixed tickets#8934
LicenseMIT
Doc PR~

TODO

  • Fix wrong xml configuration definition
  • Write documentation (new entry or replace symfony.com/doc/current/cookbook/request/mime_type.html ?)

->info('request configuration')
->canBeUnset()
->children()
->arrayNode('additionnal_formats')
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Yes indeed... Sorry

@hacfi
Copy link
Contributor

+1

AsseticBundle currently has a RequestListener which just adds additional formats. It makes sense to let bundles use this feature too. So how about adding a service tag?

@stof
Copy link
Member

stof commentedSep 6, 2013

@hacfi Additional formats are not services. So using a tag would require creating hacky services.

Such bundles shouldprepend configurations if they want to add some formats

->arrayNode('request')
->info('request configuration')
->canBeUnset()
->children()
Copy link
Member

Choose a reason for hiding this comment

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

You are missing the->fixXmlConfig('additional_format') call to make the prototyped node work properly for XML configs

@stof
Copy link
Member

stof commentedSep 6, 2013

the XSD must be updated as well

@hacfi
Copy link
Contributor

@stof Good to know - thanks!

@gquemener
Copy link
ContributorAuthor

I'm wondering, does it worth it to add asetFormats method inside the listener in order to allow injecting the formats manually?

@hacfi
Copy link
Contributor

@gquemener What do you mean by injecting formats manually?

As the listener will only use onKernelRequest I suggest to use an event listener instead of a subscriber. What do you think?

@gquemener
Copy link
ContributorAuthor

@hacfi I was thinking of injecting the formats from a controller, but it doesn't make any sense. Let's forget the idea!

@gquemener
Copy link
ContributorAuthor

@gquemener
Copy link
ContributorAuthor

@stof I've updated the xsd to allow using the following structure:

  <request>    <additional-formatname="csv">      <mime-type>text/csv</mime-type>    </additional-format>  </request>

What do you think about it and does theConfiguration class needs some changes, please?

@stof
Copy link
Member

stof commentedSep 6, 2013

@gquemener The XML would not look like this but will be

<request>    <additional-formatname="csv">text/csv</additional-format>    <additional-formatname="gif">imgae/gif</additional-format>  </request>

as it is a scalar prototype

->fixXmlConfig('additional-format')
->children()
->arrayNode('additional_formats')
->prototype('array')
Copy link
Member

Choose a reason for hiding this comment

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

you are still missing the call touseAttributeAsKey. Please add a test using this feature in different formats to see that it is broken currently

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Ok thanks, will do soon

@lsmith77
Copy link
Contributor

Btw FOSRestBundle also already provides this

<xsd:choice minOccurs="1" maxOccurs="unbounded">
<xsd:element name="mime-type" type="xsd:string" />
</xsd:choice>
<xsd:attribute name="name" type="xsd:string" />
Copy link
Member

Choose a reason for hiding this comment

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

you should mark this attribute as required as we use it as key

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Ok thanks I'll fix it.

I'm still having issue finding the correct way to supporthttps://github.com/symfony/symfony/pull/8944/files#L11R131 using xml.

@docteurklein rose up the fact that it might not be possible (gquemener@b41388e#commitcomment-4065417), but the FrameworkExtensionTest architecture suggest that all configuration format should behave identically. Is it okay if it's not the case?

I mean, is it ok if it's not possible to define multiple mime-types for a given format when using xml?

@jakzal
Copy link
Contributor

@gquemener are you still interested in finishing this one off? Does it still make sense ifFOSRestBundle already provides this feature and we've gota cookbook on how to do it with a request listener?

{
$this->assertEquals(array(
KernelEvents::REQUEST => 'onKernelRequest',
), AddRequestFormatsListener::getSubscribedEvents());
Copy link
Contributor

Choose a reason for hiding this comment

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

is this indentation correct?

@gquemener
Copy link
ContributorAuthor

@jakzal Yes I'm still interested but I was struggling with the xml configuration definition, and didn't have time to find the correct solution.

I think it'd be interesting to have this configuration directly into Symfony (as you might want to use it without using FOSRestBundle, as you don't want any rest api). Anyway, As I say, I'm hardly struggling with the xml definition, so I'm gonna take a look at how FOSRestBundle did it.

@cordoval
Copy link
Contributor

is it the schema thing@gquemener ? or other part of configurations? just curious

@gquemener
Copy link
ContributorAuthor

Yes it's the xml schema. AFAIR, I had trouble defining the additionnal formats the same way in yaml and in xml.

@cordoval
Copy link
Contributor

something that may help is a library i saw the other day it would turn yml -> xml schema i think, but i may be wrong, let me check the lib and come back to you, maybe it can help but if not then so be it. 👶

@cordoval
Copy link
Contributor

@gquemenerromaricdrigon/MetaYaml#6 this was what i was talking about, not sure how useful

@wouterj
Copy link
Member

To support your current XSD/XML, you need to add a normalizer (and I think that's perfectly valid to do):

->beforeNormalization()    ->ifTrue(function ($v) {returnis_array($v) &&isset($v['mine_type']) })    ->then(function ($v) {return$v['mine_type'] }->end()

@gquemener
Copy link
ContributorAuthor

Good to know@wouterj, I'll try asap! thanks 🎄

Conflicts:src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php
@gquemener
Copy link
ContributorAuthor

I'm closing this PR and reopening a new one, as the diff has became too huge in 3 months!

@gquemener
Copy link
ContributorAuthor

PR is coming as soon as my "backend storage" is online
capture du 2013-12-25 22 41 01

fabpot added a commit that referenced this pull requestFeb 20, 2014
…equest formats (gquemener)This PR was squashed before being merged into the 2.5-dev branch (closes#9862).Discussion----------[FrameworkBundle] Added configuration for additionnal request formats| Q             | A| ------------- | ---| Bug fix?      | no| New feature?  | yes| BC breaks?    | no| Deprecations? | no| Tests pass?   | yes| Fixed tickets |#8934| License       | MIT| Doc PR        |symfony/symfony-docs#3402Reopening of#8944# TODO  - [x] Fix wrong xml configuration definition (Thanks@wouterj)  - [x] Change configuration key `additional_formats` to a more meaningful one  - [x] Write documentation (new entry or replacehttp://symfony.com/doc/current/cookbook/request/mime_type.html ?)Commits-------f90ba11 [FrameworkBundle] Added configuration for additionnal request formats
fabpot added a commit to symfony/framework-bundle that referenced this pull requestFeb 20, 2014
…equest formats (gquemener)This PR was squashed before being merged into the 2.5-dev branch (closes #9862).Discussion----------[FrameworkBundle] Added configuration for additionnal request formats| Q             | A| ------------- | ---| Bug fix?      | no| New feature?  | yes| BC breaks?    | no| Deprecations? | no| Tests pass?   | yes| Fixed tickets |symfony/symfony#8934| License       | MIT| Doc PR        |symfony/symfony-docs#3402Reopening ofsymfony/symfony#8944# TODO  - [x] Fix wrong xml configuration definition (Thanks@wouterj)  - [x] Change configuration key `additional_formats` to a more meaningful one  - [x] Write documentation (new entry or replacehttp://symfony.com/doc/current/cookbook/request/mime_type.html ?)Commits-------f90ba11 [FrameworkBundle] Added configuration for additionnal request formats
fabpot added a commit to symfony/http-kernel that referenced this pull requestFeb 20, 2014
…equest formats (gquemener)This PR was squashed before being merged into the 2.5-dev branch (closes #9862).Discussion----------[FrameworkBundle] Added configuration for additionnal request formats| Q             | A| ------------- | ---| Bug fix?      | no| New feature?  | yes| BC breaks?    | no| Deprecations? | no| Tests pass?   | yes| Fixed tickets |symfony/symfony#8934| License       | MIT| Doc PR        |symfony/symfony-docs#3402Reopening ofsymfony/symfony#8944# TODO  - [x] Fix wrong xml configuration definition (Thanks@wouterj)  - [x] Change configuration key `additional_formats` to a more meaningful one  - [x] Write documentation (new entry or replacehttp://symfony.com/doc/current/cookbook/request/mime_type.html ?)Commits-------f90ba11 [FrameworkBundle] Added configuration for additionnal request formats
fabpot added a commit to symfony/framework-bundle that referenced this pull requestNov 11, 2014
…equest formats (gquemener)This PR was squashed before being merged into the 2.5-dev branch (closes #9862).Discussion----------[FrameworkBundle] Added configuration for additionnal request formats| Q             | A| ------------- | ---| Bug fix?      | no| New feature?  | yes| BC breaks?    | no| Deprecations? | no| Tests pass?   | yes| Fixed tickets |symfony/symfony#8934| License       | MIT| Doc PR        |symfony/symfony-docs#3402Reopening ofsymfony/symfony#8944# TODO  - [x] Fix wrong xml configuration definition (Thanks@wouterj)  - [x] Change configuration key `additional_formats` to a more meaningful one  - [x] Write documentation (new entry or replacehttp://symfony.com/doc/current/cookbook/request/mime_type.html ?)Commits-------f90ba11 [FrameworkBundle] Added configuration for additionnal request formats
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers
No reviews
Assignees
No one assigned
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

7 participants
@gquemener@hacfi@stof@lsmith77@jakzal@cordoval@wouterj

[8]ページ先頭

©2009-2025 Movatter.jp