|
|
|
@ -34,6 +34,13 @@ class MimeTypeController extends Controller
|
|
|
|
|
]; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* @var array MIME types to add to the ones parsed from Apache files |
|
|
|
|
*/ |
|
|
|
|
private $additionalMimeTypes = [ |
|
|
|
|
'mjs' => 'text/javascript', |
|
|
|
|
]; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* @param string $outFile the mime file to update. Defaults to @yii/helpers/mimeTypes.php |
|
|
|
|
* @param string $aliasesOutFile the aliases file to update. Defaults to @yii/helpers/mimeAliases.php |
|
|
|
|
*/ |
|
|
|
@ -47,9 +54,9 @@ class MimeTypeController extends Controller
|
|
|
|
|
$aliasesOutFile = Yii::getAlias('@yii/helpers/mimeAliases.php'); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$this->stdout('downloading mime-type file from apache httpd repository...'); |
|
|
|
|
$this->stdout('Downloading mime-type file from apache httpd repository...'); |
|
|
|
|
if ($apacheMimeTypesFileContent = file_get_contents('http://svn.apache.org/viewvc/httpd/httpd/trunk/docs/conf/mime.types?view=co')) { |
|
|
|
|
$this->stdout("done.\n", Console::FG_GREEN); |
|
|
|
|
$this->stdout("Done.\n", Console::FG_GREEN); |
|
|
|
|
$this->generateMimeTypesFile($outFile, $apacheMimeTypesFileContent); |
|
|
|
|
$this->generateMimeAliasesFile($aliasesOutFile); |
|
|
|
|
} else { |
|
|
|
@ -63,7 +70,7 @@ class MimeTypeController extends Controller
|
|
|
|
|
*/ |
|
|
|
|
private function generateMimeTypesFile($outFile, $content) |
|
|
|
|
{ |
|
|
|
|
$this->stdout("generating file $outFile..."); |
|
|
|
|
$this->stdout("Generating file $outFile..."); |
|
|
|
|
$mimeMap = []; |
|
|
|
|
foreach (explode("\n", $content) as $line) { |
|
|
|
|
$line = trim($line); |
|
|
|
@ -78,6 +85,7 @@ class MimeTypeController extends Controller
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
$mimeMap = array_merge($mimeMap, $this->additionalMimeTypes); |
|
|
|
|
ksort($mimeMap); |
|
|
|
|
$array = VarDumper::export($mimeMap); |
|
|
|
|
$content = <<<EOD |
|
|
|
|