Updated Drupal to 8.6. This goes with the following updates because it's possible...
[yaffs-website] / web / core / modules / media / src / Plugin / media / Source / File.php
index 0f7631ec2771516af230a81591608e766a66dd5a..1c963ef9636b948c9c3bf5715b6d43376e5977bb 100644 (file)
@@ -22,6 +22,13 @@ use Drupal\media\MediaSourceBase;
  */
 class File extends MediaSourceBase {
 
+  /**
+   * Key for "Name" metadata attribute.
+   *
+   * @var string
+   */
+  const METADATA_ATTRIBUTE_NAME = 'name';
+
   /**
    * Key for "MIME type" metadata attribute.
    *
@@ -36,12 +43,12 @@ class File extends MediaSourceBase {
    */
   const METADATA_ATTRIBUTE_SIZE = 'filesize';
 
-
   /**
    * {@inheritdoc}
    */
   public function getMetadataAttributes() {
     return [
+      static::METADATA_ATTRIBUTE_NAME => $this->t('Name'),
       static::METADATA_ATTRIBUTE_MIME => $this->t('MIME type'),
       static::METADATA_ATTRIBUTE_SIZE => $this->t('File size'),
     ];
@@ -58,15 +65,16 @@ class File extends MediaSourceBase {
       return parent::getMetadata($media, $attribute_name);
     }
     switch ($attribute_name) {
-      case 'mimetype':
+      case static::METADATA_ATTRIBUTE_NAME:
+      case 'default_name':
+        return $file->getFilename();
+
+      case static::METADATA_ATTRIBUTE_MIME:
         return $file->getMimeType();
 
-      case 'filesize':
+      case static::METADATA_ATTRIBUTE_SIZE:
         return $file->getSize();
 
-      case 'default_name':
-        return $file->getFilename();
-
       case 'thumbnail_uri':
         return $this->getThumbnail($file) ?: parent::getMetadata($media, $attribute_name);