‪TYPO3CMS  9.5
OnlineMediaHelperRegistry.php
Go to the documentation of this file.
1 <?php
3 
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 
20 
25 {
31  public static function ‪getInstance()
32  {
33  return GeneralUtility::makeInstance(self::class);
34  }
35 
42  public function ‪getOnlineMediaHelper(‪File $file)
43  {
44  $registeredHelpers = ‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['fal']['onlineMediaHelpers'];
45  if (isset($registeredHelpers[$file->‪getExtension()])) {
46  return GeneralUtility::makeInstance($registeredHelpers[$file->‪getExtension()], $file->‪getExtension());
47  }
48  return false;
49  }
50 
59  public function ‪transformUrlToFile($url, ‪Folder $targetFolder, $allowedExtensions = [])
60  {
61  $registeredHelpers = ‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['fal']['onlineMediaHelpers'];
62  foreach ($registeredHelpers as $extension => $className) {
63  if (!empty($allowedExtensions) && !in_array($extension, $allowedExtensions, true)) {
64  continue;
65  }
67  $helper = GeneralUtility::makeInstance($className, $extension);
68  $file = $helper->transformUrlToFile($url, $targetFolder);
69  if ($file !== null) {
70  return $file;
71  }
72  }
73  return null;
74  }
75 
82  {
83  return array_keys(‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['fal']['onlineMediaHelpers']);
84  }
85 }
‪TYPO3\CMS\Core\Resource\OnlineMedia\Helpers\OnlineMediaHelperRegistry
Definition: OnlineMediaHelperRegistry.php:25
‪TYPO3\CMS\Core\Resource\OnlineMedia\Helpers\OnlineMediaHelperRegistry\transformUrlToFile
‪File null transformUrlToFile($url, Folder $targetFolder, $allowedExtensions=[])
Definition: OnlineMediaHelperRegistry.php:59
‪TYPO3\CMS\Core\Resource\OnlineMedia\Helpers\OnlineMediaHelperRegistry\getSupportedFileExtensions
‪string[] getSupportedFileExtensions()
Definition: OnlineMediaHelperRegistry.php:81
‪TYPO3\CMS\Core\Resource\OnlineMedia\Helpers\OnlineMediaHelperRegistry\getOnlineMediaHelper
‪bool OnlineMediaHelperInterface getOnlineMediaHelper(File $file)
Definition: OnlineMediaHelperRegistry.php:42
‪TYPO3\CMS\Core\Resource\Folder
Definition: Folder.php:34
‪TYPO3\CMS\Core\Resource\File
Definition: File.php:23
‪TYPO3\CMS\Core\Resource\OnlineMedia\Helpers\OnlineMediaHelperRegistry\getInstance
‪static OnlineMediaHelperRegistry getInstance()
Definition: OnlineMediaHelperRegistry.php:31
‪TYPO3\CMS\Core\Resource\AbstractFile\getExtension
‪string getExtension()
Definition: AbstractFile.php:252
‪TYPO3\CMS\Core\SingletonInterface
Definition: SingletonInterface.php:22
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:5
‪TYPO3\CMS\Core\Resource\OnlineMedia\Helpers\OnlineMediaHelperInterface
Definition: OnlineMediaHelperInterface.php:24
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:45
‪TYPO3\CMS\Core\Resource\OnlineMedia\Helpers
Definition: AbstractOEmbedHelper.php:2