-
Notifications
You must be signed in to change notification settings - Fork 1
v3.0.1 #44
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
base: main
Are you sure you want to change the base?
v3.0.1 #44
Conversation
| // Sync is_vertical when mezzanine_ref changes | ||
| $oldMezzanineRef = null; | ||
| if ($pbjxEvent->hasParentEvent()) { | ||
| $parentEvent = $pbjxEvent->getParentEvent()->getMessage(); | ||
| if ($parentEvent->has('old_node')) { | ||
| $oldMezzanineRef = $parentEvent->get('old_node')->fget('mezzanine_ref'); | ||
| } | ||
| } | ||
| $newMezzanineRef = $node->fget('mezzanine_ref'); | ||
|
|
||
| if ($newMezzanineRef !== $oldMezzanineRef) { | ||
| $mezzanineRef = $node->get('mezzanine_ref'); | ||
| $videoAsset = $this->ncr->getNode($mezzanineRef, false, ['causator' => $pbjxEvent]); | ||
|
|
||
| if ($videoAsset::schema()->hasField('is_vertical')) { | ||
| $node->set('is_vertical', $videoAsset->get('is_vertical')); | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@guizzettic this avoids the awkwardness of fgetting the mezz ref and then later regular getting it. also the second schema check is probably unnecessary, anyone who adopts one will adopt the other
diff --git a/src/Ovp/VideoEnricher.php b/src/Ovp/VideoEnricher.php
index b04dcd6..da38ffb 100644
--- a/src/Ovp/VideoEnricher.php
+++ b/src/Ovp/VideoEnricher.php
@@ -59,23 +59,17 @@ class VideoEnricher implements EventSubscriber, PbjxEnricher
}
// Sync is_vertical when mezzanine_ref changes
- $oldMezzanineRef = null;
if ($pbjxEvent->hasParentEvent()) {
$parentEvent = $pbjxEvent->getParentEvent()->getMessage();
- if ($parentEvent->has('old_node')) {
- $oldMezzanineRef = $parentEvent->get('old_node')->fget('mezzanine_ref');
- }
- }
- $newMezzanineRef = $node->fget('mezzanine_ref');
-
- if ($newMezzanineRef !== $oldMezzanineRef) {
- $mezzanineRef = $node->get('mezzanine_ref');
- $videoAsset = $this->ncr->getNode($mezzanineRef, false, ['causator' => $pbjxEvent]);
-
- if ($videoAsset::schema()->hasField('is_vertical')) {
- $node->set('is_vertical', $videoAsset->get('is_vertical'));
+ if (
+ $parentEvent->has('old_node')
+ && $node->fget('mezzanine_ref') === $parentEvent->get('old_node')->fget('mezzanine_ref')
+ ) {
+ return;
}
}
+ $videoAsset = $this->ncr->getNode($node->get('mezzanine_ref'), false, ['causator' => $pbjxEvent]);
+ $node->set('is_vertical', $videoAsset->get('is_vertical'));
}
protected function enrichWithCaptionUrls(Message $node): voidThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@efjacobson Yeah this is much cleaner 👍
| return; | ||
| } | ||
| } | ||
| $videoAsset = $this->ncr->getNode($node->get('mezzanine_ref'), false, ['causator' => $pbjxEvent]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@guizzettic the create commands for both the video and the asset are sent at the same time so it's almost guaranteed that the asset won't be available during that enrichment. that's not a problem because the is_vertical will have been set to the same value, but this getNode call will throw. so you should catch NodeNotFound here - if it throws and the parentEvent exists and is a create command, that's fine, but if it is anything else then rethrow
edit: actually, you can probably just check hasNode first
is_verticalfrom video asset to video inVideoEnricherwhen mezzanine changes.