ILIAS  trunk Revision v13.0_alpha-62-g3b72d83f2e5
ILIAS\Filesystem\Provider\DelegatingFilesystemFactory Class Reference

The delegating filesystem factory delegates the instance creation to the factory of the concrete implementation and applies all necessary decorators. More...

+ Inheritance diagram for ILIAS\Filesystem\Provider\DelegatingFilesystemFactory:
+ Collaboration diagram for ILIAS\Filesystem\Provider\DelegatingFilesystemFactory:

Public Member Functions

 __construct (private FilenameSanitizer $sanitizer, private DirectoryPathConfig $directory_path_config)
 DelegatingFilesystemFactory constructor. More...
 
 getLocal (LocalConfig $config, bool $read_only=false)
 @deprectaed More...
 
 buildFor (string $fqdn_interface, bool $read_only=false)
 
 getLocal (LocalConfig $config, bool $read_only=false)
 
 buildFor (string $fqdn_interface, bool $read_only=false)
 

Private Attributes

FlySystemFilesystemFactory $implementation
 

Detailed Description

The delegating filesystem factory delegates the instance creation to the factory of the concrete implementation and applies all necessary decorators.

Author
Nicolas Schäfli ns@st.nosp@m.uder.nosp@m.-raim.nosp@m.ann..nosp@m.ch
Fabian Schmid fabia.nosp@m.n@sr.nosp@m..solu.nosp@m.tion.nosp@m.s

Definition at line 44 of file DelegatingFilesystemFactory.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\Filesystem\Provider\DelegatingFilesystemFactory::__construct ( private FilenameSanitizer  $sanitizer,
private DirectoryPathConfig  $directory_path_config 
)

DelegatingFilesystemFactory constructor.

Definition at line 51 of file DelegatingFilesystemFactory.php.

54 {
55 /*
56 * ---------- ABSTRACTION SWITCH -------------
57 * Change the factory to switch to another filesystem abstraction!
58 * current: FlySystem from the php league
59 * -------------------------------------------
60 */
61 $this->implementation = new FlySystemFilesystemFactory();
62 }

Member Function Documentation

◆ buildFor()

ILIAS\Filesystem\Provider\DelegatingFilesystemFactory::buildFor ( string  $fqdn_interface,
bool  $read_only = false 
)

Implements ILIAS\Filesystem\Provider\FilesystemFactory.

Definition at line 77 of file DelegatingFilesystemFactory.php.

77 : Filesystem
78 {
79 $config = match ($fqdn_interface) {
80 FilesystemWeb::class => new LocalConfig($this->directory_path_config->getWebDirectoryPath()),
81 FilesystemStorage::class => new LocalConfig($this->directory_path_config->getStorageDirectoryPath()),
82 FilesystemTemp::class => new LocalConfig($this->directory_path_config->getTempDirectoryPath()),
83 FilesystemCustomizing::class => new LocalConfig(
84 $this->directory_path_config->getCustomizingDirectoryPath()
85 ),
86 FilesystemLibs::class => new LocalConfig($this->directory_path_config->getLibsDirectoryPath()),
87 FilesystemNodeModules::class => new LocalConfig(
88 $this->directory_path_config->getNodeModulesDirectoryPath()
89 ),
90 default => throw new \InvalidArgumentException("Unknown filesystem interface $fqdn_interface")
91 };
92
93 // the code directories are never written to at runtime
94 $read_only = $read_only || in_array(
95 $fqdn_interface,
96 [FilesystemLibs::class, FilesystemNodeModules::class],
97 true
98 );
99
100 if ($read_only) {
101 return new ReadOnlyDecorator(
102 new FilesystemWhitelistDecorator($this->implementation->getLocal($config), $this->sanitizer)
103 );
104 }
105 return new FilesystemWhitelistDecorator($this->implementation->getLocal($config), $this->sanitizer);
106 }
This class is used to configure the local filesystem adapter.
Definition: LocalConfig.php:30

◆ getLocal()

ILIAS\Filesystem\Provider\DelegatingFilesystemFactory::getLocal ( LocalConfig  $config,
bool  $read_only = false 
)

@deprectaed

Implements ILIAS\Filesystem\Provider\FilesystemFactory.

Definition at line 67 of file DelegatingFilesystemFactory.php.

67 : Filesystem
68 {
69 if ($read_only) {
70 return new ReadOnlyDecorator(
71 new FilesystemWhitelistDecorator($this->implementation->getLocal($config), $this->sanitizer)
72 );
73 }
74 return new FilesystemWhitelistDecorator($this->implementation->getLocal($config), $this->sanitizer);
75 }

Field Documentation

◆ $implementation

FlySystemFilesystemFactory ILIAS\Filesystem\Provider\DelegatingFilesystemFactory::$implementation
private

Definition at line 46 of file DelegatingFilesystemFactory.php.


The documentation for this class was generated from the following file: