This can be simplified to:
/**
* @param \Magento\Catalog\Model\Product\Gallery\CreateHandler $mediaGalleryCreateHandler
* @param string $entityType
* @param \Magento\Catalog\Model\Product $product
* @return void
*/
public function beforeExecute(
\Magento\Catalog\Model\Product\Gallery\CreateHandler $mediaGalleryCreateHandler,
$entityType,
\Magento\Catalog\Model\Product $product
) {
$attribute = $mediaGalleryCreateHandler->getAttribute();
$mediaCollection = $this->getMediaEntriesDataCollection($product, $attribute);
if (!empty($mediaCollection)) {
$storeDataCollection = $this->loadStoreViewVideoData($mediaCollection, $product->getStoreId());
$mediaCollection = $this->addAdditionalStoreData($mediaCollection, $storeDataCollection);
$product->setData(
$attribute->getAttributeCode(),
$mediaCollection + $product->getData($attribute->getAttributeCode())
);
}
}
A trick: a «before» plugin can return nothing if it needs not modify any argument