/** * {@inheritDoc} */ public function prepare(MediaInterface $media, ContextInterface $context) { $id = $this->getIdFromContent($media->getContent()); if ($id !== NULL) { $this->service->load($id); $previewImageUrl = $this->service->getMetaValue('thumbnail_large'); $previewImageFile = sprintf('%svimeo_preview_%s.jpg', $this->tempDir, $id); $this->addTempFile($previewImageFile); if (!file_exists($previewImageFile)) { $this->downloadFile($previewImageUrl, $previewImageFile, $media); } $media->setContent($previewImageFile); $media->setMetaValue('id', $id); if (isset($this->options['metadata'])) { foreach ((array) $this->options['metadata'] as $metaName => $mediaMetaName) { $value = $this->service->getMetaValue($metaName); if ($value !== NULL) { $media->setMetaValue($mediaMetaName, $value); } } } } }
/** * {@inheritDoc} */ public function prepare(MediaInterface $media, ContextInterface $context) { $media->setMetaValue('id', md5_file($media->getContent())); }
/** * {@inheritDoc} */ public function hasChangedContent(MediaInterface $media) { return $media->getContent() != NULL && $this->getIdFromContent($media) !== $media->getMetaValue('id'); }
/** * {@inheritDoc} */ public function hasChangedContent(MediaInterface $media) { return $media->getContent() !== NULL; }