You are here

public function MediaFeedsInternetProvider::getExistingFile in Media Feeds 7

Looks for an existing file.

Return value

The fid, if an existing file is in the database. FALSE if no existing file is found.

3 calls to MediaFeedsInternetProvider::getExistingFile()
MediaFeedsInternetProvider::getFileObject in includes/MediaFeedsInternetProvider.inc
Get the file object that can be validated and saved.
MediaFeedsInternetProvider::save in includes/MediaFeedsInternetProvider.inc
Let the provider save the file. Since providers don't use the workaround at MediaFeedsProviderWrapper::getFileObject() internally, hook into that process using hook_file_presave().
MediaFeedsInternetProvider::validate in includes/MediaFeedsInternetProvider.inc
If required, providers can validate the embedCode.

File

includes/MediaFeedsInternetProvider.inc, line 37
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 getExistingFile() {
  if ($this->existingFile === NULL) {
    $this->existingFile = FALSE;
    $file = $this->provider
      ->getFileObject();
    if ($file) {
      $query = new EntityFieldQuery();
      $existing = $query
        ->entityCondition('entity_type', 'file')
        ->propertyCondition('uri', $file->uri)
        ->execute();
      if ($existing && isset($existing['file']) && is_array($existing['file'])) {
        $this->existingFile = reset($existing['file'])->fid;
      }
    }
  }
  return $this->existingFile;
}