You are here

public function MediaFeedsInternetProvider::getFileObject in Media Feeds 7

Same name and namespace in other branches
  1. 7.2 includes/MediaFeedsInternetProvider.inc \MediaFeedsInternetProvider::getFileObject()

Get the file object that can be validated and saved.

When saving an existing file $file->fid must be this fid of the existing file and $file->is_new must be FALSE. Otherwise a PDOException will be thrown, because the file uri is a unique key.

See for example: Trying to add the same YouTube URL twice causes a primary key violation (http://drupal.org/node/952422).

Instead of skipping those files (by failing validation) we must work around that issue.

Overrides MediaFeedsProvider::getFileObject

File

includes/MediaFeedsInternetProvider.inc, line 88
Provides a wrapper class for media_internet providers.

Class

MediaFeedsInternetProvider
Wraps a media_internet provider to implement the interface of MediaFeedsProvider and provide workarounds for some issues. As the issues get fixed the workarounds can be removed.

Code

public function getFileObject() {
  $file = $this->provider
    ->getFileObject();
  $fid = $this
    ->getExistingFile();
  if ($fid) {
    $file->fid = $fid;
    $file->is_new = FALSE;
  }
  return $file;
}