‪TYPO3CMS  ‪main
DuplicationBehavior.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
19 
23 
28 {
34  case RENAME = 'rename';
35 
41  case REPLACE = 'replace';
42 
48  case CANCEL = 'cancel';
49 
53  public static function ‪getDefaultDuplicationBehaviour(?‪BackendUserAuthentication $backendUserAuthentication = null): ‪DuplicationBehavior
54  {
55  if ($backendUserAuthentication === null) {
56  return self::CANCEL;
57  }
58  $defaultAction = $backendUserAuthentication->getTSConfig()['options.']['file_list.']['uploader.']['defaultAction'] ?? '';
59 
60  if ($defaultAction === '') {
61  return self::CANCEL;
62  }
63 
64  $duplicationBehavior = self::tryFrom($defaultAction);
65  if ($duplicationBehavior !== null) {
66  return $duplicationBehavior;
67  }
68 
69  GeneralUtility::makeInstance(LogManager::class)
70  ->getLogger(__CLASS__)
71  ->warning('TSConfig: options.file_list.uploader.defaultAction contains an invalid value ("{value}"), fallback to default value: "{default}"', [
72  'value' => $defaultAction,
73  'default' => self::CANCEL->value,
74  ]);
75 
76  return self::CANCEL;
77  }
78 }
‪TYPO3\CMS\Core\Resource\Enum
Definition: DuplicationBehavior.php:18
‪TYPO3\CMS\Core\Resource\Enum\getDefaultDuplicationBehaviour
‪@ getDefaultDuplicationBehaviour
Definition: DuplicationBehavior.php:53
‪TYPO3\CMS\Core\Resource\Enum\DuplicationBehavior
‪DuplicationBehavior
Definition: DuplicationBehavior.php:28
‪TYPO3\CMS\Core\Authentication\BackendUserAuthentication
Definition: BackendUserAuthentication.php:62
‪TYPO3\CMS\Core\Log\LogManager
Definition: LogManager.php:33
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:52