Skip to content

Commit

Permalink
Merge 9d3c98f into 2f148aa
Browse files Browse the repository at this point in the history
  • Loading branch information
mcaskill committed Apr 15, 2020
2 parents 2f148aa + 9d3c98f commit d0b6fb3
Show file tree
Hide file tree
Showing 19 changed files with 1,685 additions and 387 deletions.
6 changes: 3 additions & 3 deletions composer.json
Expand Up @@ -19,14 +19,14 @@
"prefer-stable": true,
"extra": {
"branch-alias": {
"dev-master": "0.10.x-dev"
"dev-master": "0.11.x-dev"
}
},
"require": {
"php": ">=5.6.0 || >=7.0",
"ext-fileinfo": "*",
"ext-PDO": "*",
"ext-SimpleXML": "*",
"ext-pdo": "*",
"ext-simplexml": "*",
"psr/log": "^1.0",
"psr/cache": "^1.0",
"locomotivemtl/charcoal-config": "~0.9",
Expand Down
39 changes: 20 additions & 19 deletions src/Charcoal/Property/AudioProperty.php
Expand Up @@ -85,51 +85,52 @@ public function getMaxLength()
}

/**
* Retrieves the default list of acceptable MIME types for uploaded files.
*
* This method should be overriden.
*
* @return string[]
*/
public function getAcceptedMimetypes()
public function getDefaultAcceptedMimetypes()
{
return [
'audio/mp3',
'audio/mpeg',
'audio/ogg',
'audio/webm',
'audio/wav',
'audio/wave',
'audio/x-wav',
'audio/x-pn-wav',
];
}

/**
* Generate the file extension from the property's value.
* Resolve the file extension from the given MIME type.
*
* @param string $file The file to parse.
* @return string The extension based on the MIME type.
* @param string $type The MIME type to resolve.
* @return string|null The extension based on the MIME type.
*/
public function generateExtension($file = null)
protected function resolveExtensionFromMimeType($type)
{
if (is_string($file)) {
if (in_array($file, $this->getAcceptedMimetypes())) {
$mime = $file;
} else {
$mime = $this->getMimetypeFor($file);
}
} else {
$mime = $this->getMimetype();
}

switch ($mime) {
switch ($type) {
case 'audio/mp3':
case 'audio/mpeg':
return 'mp3';

case 'audio/ogg':
return 'ogg';

case 'audio/webm':
return 'webm';

case 'audio/wav':
case 'audio/wave':
case 'audio/x-wav':
case 'audio/x-pn-wav':
return 'wav';

default:
return '';
}

return null;
}
}

0 comments on commit d0b6fb3

Please sign in to comment.