You are here

entity_share_medias_file.export.inc in Entity Share 7

Class for handling File Medias Export.

File

modules/entity_share_medias/modules/entity_share_medias_file/includes/entity_share_medias_file.export.inc
View source
<?php

/**
 * @file
 * Class for handling File Medias Export.
 */

/**
 * Class for file export.
 */
class EntityShareMediasFileExport extends EntityShareMediasFileAbstract implements EntityShareMediasExportInterface {

  /**
   * Load File.
   *
   * @param int $fid
   *   File id.
   *
   * @return object
   *   The file object.
   */
  protected function loadFile($fid) {
    $file = file_load($fid);

    // Add entity_share property to the entity.
    $this->entity->entity_share->file[$fid] = $file;
    return $file;
  }

  /**
   * Export the medias of the provider.
   */
  public function exportMedias() {

    // Alter the field_data.
    if ($this
      ->isRteField()) {
      $this
        ->rteManagement();
    }
    else {
      $this
        ->fieldManagement();
    }
  }

  /**
   * Alter RTE datas.
   */
  protected function rteManagement() {
  }

  /**
   * Manage field media reference content.
   */
  protected function fieldManagement() {
    if (is_object($this->fieldData)) {
      $this->fieldData = (array) $this->fieldData;
    }
    $fid = $this->fieldData['fid'];
    if (!empty($fid)) {
      $file = $this
        ->loadFile($fid);
      if (!empty($file->uri)) {

        // Add the file url in a property of the scald object.
        $file->file_url = file_create_url($file->uri);
      }
      $this->fieldData = (object) array_merge((array) $file, $this->fieldData);
    }
  }

}

Classes

Namesort descending Description
EntityShareMediasFileExport Class for file export.