You are here

function Resource::save in D7 Media 6

Save the current state of a drupal_file in the database. If the file->fid is empty a new database record will be added.

Return value

bool TRUE if save succeeded, FALSE if save failed.

2 calls to Resource::save()
Resource::move in resource/resource.module
Move a Resource.
ResourceUpload::save in resource/resource.module
Save the current state of a drupal_file in the database. If the file->fid is empty a new database record will be added.
1 method overrides Resource::save()
ResourceUpload::save in resource/resource.module
Save the current state of a drupal_file in the database. If the file->fid is empty a new database record will be added.

File

resource/resource.module, line 274
Resource API for Drupal, a replacement for files.

Class

Resource
Base Resource class.

Code

function save() {
  $this->timestamp = time();
  $manager = DrupalStreamWrapperManager::singleton();
  $class = $manager
    ->streamWrapperClass(parse_url($this->url, PHP_URL_SCHEME));
  if ($class != get_class($this
    ->streamWrapperManager())) {
    $this->streamWrapperHandler = new $class();
  }
  $this->size = $this->streamWrapperHandler
    ->size($this->url);
  $this->mime = $this->streamWrapperHandler
    ->mime($this->url);
  if (empty($this->fid)) {
    $result = drupal_write_record('resource', $this);
    module_invoke_all('resource_insert', $this);
  }
  else {
    $result = drupal_write_record('resource', $this, 'rid');
    module_invoke_all('resource_update', $this);
  }
  return $result;
}