Skip to content

Deprecate MediaProviderInterface::validate()#2499

Draft
dmaicher wants to merge 1 commit intosonata-project:4.xfrom
dmaicher:deprecate_error_element
Draft

Deprecate MediaProviderInterface::validate()#2499
dmaicher wants to merge 1 commit intosonata-project:4.xfrom
dmaicher:deprecate_error_element

Conversation

@dmaicher
Copy link
Contributor

Subject

I am targeting this branch, because {reason}.

Relates to sonata-project/form-extensions#333

Changelog

### Deprecated
- `MediaProviderInterface::validate()` is deprecated. Implement `validateMedia()` instead. 

To do

  • Add more tests
  • documentation update?

@sonata-project/contributors this is a draft for now. Before I continue to finalize it I wanted to get your feedback on it.

To achieve sonata-project/form-extensions#333 we need to get rid of ErrorElement and InlineConstraint usages here.

From what I see we can easily achieve the validation with the proposed approach here by introducing a new validateMedia() method.

WDYT?

@dmaicher dmaicher force-pushed the deprecate_error_element branch from cdceb01 to c100b76 Compare September 30, 2025 14:57
@OskarStark OskarStark changed the title Deprecate MediaProviderInterface::valdate() Deprecate MediaProviderInterface::validate() Sep 30, 2025
Copy link
Member

@VincentLanglet VincentLanglet left a comment

Choose a reason for hiding this comment

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

Seems an interesting solution, the only issue I see

}

public function validate(ErrorElement $errorElement, MediaInterface $media): void
public function validateMedia(ExecutionContextInterface $context, MediaInterface $media): void
Copy link
Member

Choose a reason for hiding this comment

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

There is no BC break issue if someone is extending the validate method ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It should be compatible as I added those checks if a child class overwrites them inside BaseProvider 🤔

@dmaicher
Copy link
Contributor Author

* If it's really Backward compatible for someone overriding validate method (and eventually rely on parent::validate)

Should be. See #2499 (comment)

* We have BlockBundle using it a lot https://github.com/search?q=repo%3Asonata-project%2FSonataBlockBundle%20ErrorElement&type=code and every bundle implementing those interface. Like SonataPageBundle or SonataClassificationBundle.

Yeah that would indeed be the bigger work to deprecate and fix those 😢

* More important, with our lack of maintainer/contributor, I dunno if there will be a new major one day and when...

Valid point. Maybe its not worth it for now anyway. I don't use this bundle myself anyway.

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.

2 participants