You are here

RemoteFile.php in File URL 2.0.x

Same filename and directory in other branches
  1. 8 src/Entity/RemoteFile.php

File

src/Entity/RemoteFile.php
View source
<?php

namespace Drupal\file_url\Entity;

use Drupal\file\Entity\File;

/**
 * Defines the remote file entity class.
 *
 * @ingroup file
 *
 * @ContentEntityType(
 *   id = "remote_file",
 *   label = @Translation("Remote file"),
 *   handlers = {
 *     "storage" = "Drupal\Core\Entity\ContentEntityNullStorage",
 *   },
 *   base_table = "file_managed",
 *   entity_keys = {
 *     "id" = "fid",
 *     "label" = "filename",
 *     "langcode" = "langcode",
 *     "owner" = "uid",
 *     "uuid" = "uuid"
 *   }
 * )
 */
class RemoteFile extends File {

  /**
   * {@inheritdoc}
   */
  public static function load($id) {
    return parent::create([
      'uri' => $id,
    ]);
  }

  /**
   * {@inheritdoc}
   */
  public function id() {
    return $this
      ->getFileUri();
  }

}

Classes

Namesort descending Description
RemoteFile Defines the remote file entity class.