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

[Serializer][FrameworkBundle] Add a DateInterval normalizer#23747

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
Lctrs wants to merge8 commits intosymfony:3.4fromLctrs:feature/dateinterval-normalizer
Closed

[Serializer][FrameworkBundle] Add a DateInterval normalizer#23747

Lctrs wants to merge8 commits intosymfony:3.4fromLctrs:feature/dateinterval-normalizer

Conversation

@Lctrs
Copy link
Contributor

@LctrsLctrs commentedAug 1, 2017
edited
Loading

QA
Branch?3.4
Bug fix?no
New feature?yes
BC breaks?no
Deprecations?no
Tests pass?yes
Fixed tickets
LicenseMIT
Doc PRsymfony/symfony-docs#8267

Could be useful for API needing to submit a duration.

Most code have been adapted from@MisatoTremor's DateInterval form type. Credits to him.

{
if (class_exists('Symfony\Component\Serializer\Normalizer\DataUriNormalizer')) {
// Runafter serializer.normalizer.object
// Runbefore serializer.normalizer.object
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you submit another PR to fix this in 3.3 instead?

Copy link
ContributorAuthor

@LctrsLctrsAug 2, 2017
edited
Loading

Choose a reason for hiding this comment

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

👍

Done in#23765.

@ogizanagiogizanagi added this to the3.4 milestoneAug 2, 2017
}

if (!$this->isISO8601($data)) {
thrownewUnexpectedValueException('Non ISO 8601 interval strings are not supported yet.');
Copy link
Contributor

Choose a reason for hiding this comment

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

Why "yet"? Do you plan to add support for this and how?
On the contrary, I'd change the message for "Expected a valid ISO 8601 interval string." and remove related tests/dataprovider.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Well, as I said, most code have been adapted from the DateInterval form type, and especially from the classDateIntervalToStringTransformer which have the same exception message.

I thought that if non ISO 8601 interval string support was added to this class, maybe we could port it to the DateIntervalNormalizer. But I'm not sure it's worth it or a valid use case for the Serializer part.

Copy link
Member

Choose a reason for hiding this comment

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

Agree with@ogizanagi, let's not promise something that we're not sure to want.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

I agree.

I'll try to make the requested changes before I go on holidays.

// Run before serializer.normalizer.object
$definition =$container->register('serializer.normalizer.dateinterval', DateIntervalNormalizer::class);
$definition->setPublic(false);
$definition->addTag('serializer.normalizer',array('priority' => -915));
Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

@ogizanagi are you okay with this priority ? Or should I change it to -930 to be more consistent with other normalizers ?

Copy link
Contributor

Choose a reason for hiding this comment

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

Looks good to me :)

@Lctrs
Copy link
ContributorAuthor

PR updated to fix comment made by@ogizanagi and@chalasr.

@Lctrs
Copy link
ContributorAuthor

Unless there are more comments that need to be addressed, it should be ready to merge then :)

publicfunctiondenormalize($data,$class,$format =null,array$context =array())
{
if (!is_string($data)) {
thrownewInvalidArgumentException('Data expected to be a string,'.gettype($data).' given.');
Copy link
Contributor

Choose a reason for hiding this comment

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

You should usesprintf for exception messages.

@ogizanagi
Copy link
Contributor

Could you add an entry in component's CHANGELOG.md file?

@Lctrs
Copy link
ContributorAuthor

@ogizanagi Done.

@Lctrs
Copy link
ContributorAuthor

@ogizanagi Is there anything else that prevent it from being merged ?

$transitions =array();
foreach ($workflow['transitions']as$transition) {
if ($type ==='workflow') {
if ('workflow' ===$type) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Must be reverted. This change does not belong to this PR.

if ('workflow' ===$type) {
$transitions[] =newDefinition(Workflow\Transition::class,array($transition['name'],$transition['from'],$transition['to']));
}elseif ($type ==='state_machine') {
}elseif ('state_machine' ===$type) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Same

if (ChainAdapter::class ===$parentDefinition->getClass()) {
break;
}
// no break
Copy link
Contributor

Choose a reason for hiding this comment

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

Same

@ogizanagi
Copy link
Contributor

ogizanagi commentedSep 14, 2017
edited
Loading

@Lctrs : Nothing to me (appart from the comments I've just added, since the PR was tweaked since my last review). We just miss another approval (not mandatory here, but always good to take).

ping @symfony/deciders ,@dunglas :)

@ogizanagi
Copy link
Contributor

Thank you@Lctrs.

ogizanagi added a commit that referenced this pull requestSep 15, 2017
…lizer (Lctrs)This PR was squashed before being merged into the 3.4 branch (closes#23747).Discussion----------[Serializer][FrameworkBundle] Add a DateInterval normalizer| Q             | A| ------------- | ---| Branch?       | 3.4| Bug fix?      | no| New feature?  | yes| BC breaks?    | no| Deprecations? | no| Tests pass?   | yes| Fixed tickets || License       | MIT| Doc PR        |symfony/symfony-docs#8267Could be useful for API needing to submit a duration.Most code have been adapted from@MisatoTremor's DateInterval form type. Credits to him.Commits-------6185cb1 [Serializer][FrameworkBundle] Add a DateInterval normalizer
@LctrsLctrs deleted the feature/dateinterval-normalizer branchSeptember 15, 2017 16:11
xabbuh added a commit to symfony/symfony-docs that referenced this pull requestSep 22, 2017
…alizer (Lctrs)This PR was squashed before being merged into the 3.4 branch (closes#8267).Discussion----------[Serializer] Document the new DateIntervalNormalizer normalizerWaiting forsymfony/symfony#23747 to be merged.Commits-------9784714 [Serializer] Document the new DateIntervalNormalizer normalizer
This was referencedOct 18, 2017
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@chalasrchalasrchalasr left review comments

@dunglasdunglasAwaiting requested review from dunglasdunglas is a code owner

+1 more reviewer

@ogizanagiogizanagiogizanagi approved these changes

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Projects

None yet

Milestone

3.4

Development

Successfully merging this pull request may close these issues.

4 participants

@Lctrs@ogizanagi@chalasr@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp