Problem/Motivation

Media entity used to provide custom validation API to be used by type plugins. In #2529178: Convert media type validation code to a constraint we converted this feature to core's Constraint API. All media type providers need to follow that change.

Proposed resolution

Media entity embeddable video should follow this change too. Media entity Twitter already did that in #2578927: [Chase media_entity] Convert validation to Constraints API and can be used as a reference.

Comments

slashrsm created an issue. See original summary.

rosinegrean’s picture

Assigned: Unassigned » rosinegrean
ehegedus’s picture

Assigned: rosinegrean » ehegedus

I'm on it.

primsi’s picture

Assigned: ehegedus » Unassigned
Status: Active » Needs review

Pull: https://github.com/drupal-media/media_entity_embeddable_video/pull/8

I am not sure that that's the way we wanted to approach that.

slashrsm’s picture

Status: Needs review » Needs work

Few comments on PR.

primsi’s picture

Status: Needs work » Needs review

Thanks, addressed comments and added tests. Do we need the travis config file also? Or are we doing that in a separate ticket?

slashrsm’s picture

Status: Needs review » Needs work

One comment. Yes, Travis script would be great!

primsi’s picture

Status: Needs work » Needs review

Addressed coments. I propose adding the travis script in a separate ticket.

slashrsm’s picture

Status: Needs review » Fixed

OK, lets open a followup. Merged.

  • Primsi committed 07b4696 on 8.x-1.x
    Issue #2578947 by Primsi: [Chase media_entity] Convert validation to...
primsi’s picture

axe312’s picture

Status: Fixed » Needs work
StatusFileSize
new56.98 KB
new27.99 KB

Sorry, but this is not working for youtube video urls on a link field. I attached a screenshot and a exported configuration for simplytest.me

yannickoo’s picture

Issue summary: View changes
StatusFileSize
new75.17 KB

I can confirm this! First I thought axe312 forgot the www in the URL but even with the URL from code it doesn't work :/

pixelmord’s picture

The reason here is that the regular expression is not matched against the url of the field.

Attached a patch and created a PR in github

pixelmord’s picture

primsi’s picture

+++ b/src/Plugin/Validation/Constraint/VideoProviderMatchConstraintValidator.php
@@ -20,13 +21,14 @@ class VideoProviderMatchConstraintValidator extends ConstraintValidator {
+    $url = $value->getUrl()->toString();

This would break bundles, where the field doesn't use \Drupal\Core\TypedData\Plugin\DataType\Uri, ie text areas, text fields...

I am trying to find a way to get the value in a generic way. Hopefully will come up with a PR shortly.

primsi’s picture

I've tested this approach and it seems to work for plain text field and for link fields.

Pull: https://github.com/drupal-media/media_entity_embeddable_video/pull/11

primsi’s picture

Oh, forgot. I noticed that youtube links without www fail validation anyway. That's because of the regexe syntax. If we wanted to fix that, I suggest opening a new ticket.

primsi’s picture

Status: Needs work » Needs review
slashrsm’s picture

Status: Needs review » Needs work

Looks good. Two comments on pull.

Youtube links follow-up: #2605522: Support Youtube links without www

primsi’s picture

Status: Needs work » Needs review

Addressed comments.

slashrsm’s picture

Status: Needs review » Fixed

Merged. Thanks.

Also opened #2606626: Fix Travis CI integration.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.