‪TYPO3CMS  10.4
generateMimeTypes.php
Go to the documentation of this file.
1 #!/usr/bin/env php
2 <?php
3 declare(strict_types=1);
4 /*
5  * This file is part of the TYPO3 CMS project.
6  *
7  * It is free software; you can redistribute it and/or modify it under
8  * the terms of the GNU General Public License, either version 2
9  * of the License, or any later version.
10  *
11  * For the full copyright and license information, please read the
12  * LICENSE.txt file that was distributed with this source code.
13  *
14  * The TYPO3 project - inspiring people to share!
15  */
16 
17 ‪$dbJson = file_get_contents(dirname(__DIR__) . '/node_modules/mime-db/db.json');
18 ‪$dbJson = json_decode(‪$dbJson, true);
19 
22 foreach (‪$dbJson as $mimeType => $mimeTypeInfo) {
23  if (isset($mimeTypeInfo['extensions'])) {
24  ‪$mimeTypeMapping[$mimeType] = $mimeTypeInfo['extensions'];
25  }
26 }
27 
28 // @todo: add our own file extensions here
29 
30 foreach (‪$mimeTypeMapping as $mimeType => $extensionInfo) {
31  ‪$mimeTypeString .= " '" . $mimeType . "' => ['" . implode("', '", $extensionInfo) . "'],
32 ";
33 }
34 
36 
37 declare(strict_types=1);
38 
39 /*
40  * This file is part of the TYPO3 CMS project.
41  *
42  * It is free software; you can redistribute it and/or modify it under
43  * the terms of the GNU General Public License, either version 2
44  * of the License, or any later version.
45  *
46  * For the full copyright and license information, please read the
47  * LICENSE.txt file that was distributed with this source code.
48  *
49  * The TYPO3 project - inspiring people to share!
50  */
51 
52 namespace TYPO3\CMS\Core\Resource;
53 
58 final class MimeTypeCollection
59 {
60  private $map = [
61 ' . rtrim(‪$mimeTypeString, ',') .
62 ' ];
63 
67  public function getMap(): array
68  {
69  return $this->map;
70  }
71 
75  public function getMimeTypes(): array
76  {
77  return array_keys($this->map);
78  }
79 }
80 ';
81 
82 file_put_contents(dirname(dirname(__DIR__)) . '/typo3/sysext/core/Classes/Resource/MimeTypeCollection.php', ‪$classTemplate);
‪$mimeTypeString
‪$mimeTypeString
Definition: generateMimeTypes.php:21
‪$classTemplate
‪foreach($dbJson as $mimeType=> $mimeTypeInfo) foreach($mimeTypeMapping as $mimeType=> $extensionInfo) $classTemplate
Definition: generateMimeTypes.php:35
‪$mimeTypeMapping
‪$mimeTypeMapping
Definition: generateMimeTypes.php:20
‪$dbJson
‪$dbJson
Definition: generateMimeTypes.php:17