‪TYPO3CMS  10.4
OnlineMediaHelperRegistry.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  * This file is part of the TYPO3 CMS project.
5  *
6  * It is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU General Public License, either version 2
8  * of the License, or any later version.
9  *
10  * For the full copyright and license information, please read the
11  * LICENSE.txt file that was distributed with this source code.
12  *
13  * The TYPO3 project - inspiring people to share!
14  */
15 
17 
22 
27 {
33  public static function ‪getInstance()
34  {
35  return GeneralUtility::makeInstance(self::class);
36  }
37 
44  public function ‪hasOnlineMediaHelper(string $fileExtension): bool
45  {
46  return isset(‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['fal']['onlineMediaHelpers'][$fileExtension]);
47  }
48 
55  public function ‪getOnlineMediaHelper(‪File $file)
56  {
57  $registeredHelpers = ‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['fal']['onlineMediaHelpers'];
58  if (isset($registeredHelpers[$file->‪getExtension()])) {
59  return GeneralUtility::makeInstance($registeredHelpers[$file->‪getExtension()], $file->‪getExtension());
60  }
61  return false;
62  }
63 
72  public function ‪transformUrlToFile($url, ‪Folder $targetFolder, $allowedExtensions = [])
73  {
74  $registeredHelpers = ‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['fal']['onlineMediaHelpers'];
75  foreach ($registeredHelpers as $extension => $className) {
76  if (!empty($allowedExtensions) && !in_array($extension, $allowedExtensions, true)) {
77  continue;
78  }
80  $helper = GeneralUtility::makeInstance($className, $extension);
81  $file = $helper->transformUrlToFile($url, $targetFolder);
82  if ($file !== null) {
83  return $file;
84  }
85  }
86  return null;
87  }
88 
95  {
96  return array_keys(‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['fal']['onlineMediaHelpers']);
97  }
98 }
‪TYPO3\CMS\Core\Resource\OnlineMedia\Helpers\OnlineMediaHelperRegistry
Definition: OnlineMediaHelperRegistry.php:27
‪TYPO3\CMS\Core\Resource\OnlineMedia\Helpers\OnlineMediaHelperRegistry\transformUrlToFile
‪File null transformUrlToFile($url, Folder $targetFolder, $allowedExtensions=[])
Definition: OnlineMediaHelperRegistry.php:72
‪TYPO3\CMS\Core\Resource\OnlineMedia\Helpers\OnlineMediaHelperRegistry\getSupportedFileExtensions
‪string[] getSupportedFileExtensions()
Definition: OnlineMediaHelperRegistry.php:94
‪TYPO3\CMS\Core\Resource\OnlineMedia\Helpers\OnlineMediaHelperRegistry\getOnlineMediaHelper
‪bool OnlineMediaHelperInterface getOnlineMediaHelper(File $file)
Definition: OnlineMediaHelperRegistry.php:55
‪TYPO3\CMS\Core\Resource\Folder
Definition: Folder.php:37
‪TYPO3\CMS\Core\Resource\File
Definition: File.php:24
‪TYPO3\CMS\Core\Resource\OnlineMedia\Helpers\OnlineMediaHelperRegistry\getInstance
‪static OnlineMediaHelperRegistry getInstance()
Definition: OnlineMediaHelperRegistry.php:33
‪TYPO3\CMS\Core\Resource\AbstractFile\getExtension
‪string getExtension()
Definition: AbstractFile.php:254
‪TYPO3\CMS\Core\SingletonInterface
Definition: SingletonInterface.php:23
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:5
‪TYPO3\CMS\Core\Resource\OnlineMedia\Helpers\OnlineMediaHelperInterface
Definition: OnlineMediaHelperInterface.php:25
‪TYPO3\CMS\Core\Resource\OnlineMedia\Helpers\OnlineMediaHelperRegistry\hasOnlineMediaHelper
‪bool hasOnlineMediaHelper(string $fileExtension)
Definition: OnlineMediaHelperRegistry.php:44
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:46
‪TYPO3\CMS\Core\Resource\OnlineMedia\Helpers
Definition: AbstractOEmbedHelper.php:16