39 $shortName = $shortName ?: $driverConfig[
'shortName'] ??
'';
40 $this->
registerDriverClass($driverConfig[
'class'] ??
'', $shortName, $driverConfig[
'label'] ??
'', $driverConfig[
'flexFormDS'] ??
'');
54 public function registerDriverClass($className, $shortName =
null, $label =
null, $flexFormDataStructurePathAndFilename =
null)
57 if (!class_exists($className)) {
58 throw new \InvalidArgumentException(
'Class ' . $className .
' does not exist.', 1314979197);
61 if (!in_array(DriverInterface::class, class_implements($className),
true)) {
62 throw new \InvalidArgumentException(
'Driver ' . $className .
' needs to implement the DriverInterface.', 1387619575);
64 if ($shortName ===
'') {
65 $shortName = $className;
67 if (array_key_exists($shortName, $this->drivers)) {
69 if ($this->drivers[$shortName] === $className) {
72 throw new \InvalidArgumentException(
'Driver ' . $shortName .
' is already registered.', 1314979451);
74 $this->drivers[$shortName] = $className;
75 $this->driverConfigurations[$shortName] = [
76 'class' => $className,
77 'shortName' => $shortName,
79 'flexFormDS' => $flexFormDataStructurePathAndFilename
90 $driverFieldConfig = &
$GLOBALS[
'TCA'][
'sys_file_storage'][
'columns'][
'driver'][
'config'];
91 $configurationFieldConfig = &
$GLOBALS[
'TCA'][
'sys_file_storage'][
'columns'][
'configuration'][
'config'];
92 foreach ($this->driverConfigurations as $driver) {
93 $label = $driver[
'label'] ?: $driver[
'class'];
94 $driverFieldConfig[
'items'][$driver[
'shortName']] = [$label, $driver[
'shortName']];
95 if ($driver[
'flexFormDS']) {
96 $configurationFieldConfig[
'ds'][$driver[
'shortName']] = $driver[
'flexFormDS'];
110 if (in_array($shortName, $this->drivers) && class_exists($shortName)) {
113 if (!array_key_exists($shortName, $this->drivers)) {
114 throw new \InvalidArgumentException(
115 'Desired storage "' . $shortName .
'" is not in the list of available storages.',
119 return $this->drivers[$shortName];
130 return array_key_exists($shortName, $this->drivers);