ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
FlySystemLocalFilesystemFactory.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
29 
35 {
36  public const PRIVATE_ACCESS_KEY = 'private';
37  public const PUBLIC_ACCESS_KEY = 'public';
38  public const FILE_ACCESS_KEY = 'file';
39  public const DIRECTORY_ACCESS_KEY = 'dir';
40 
47  {
48  $this->validateFileLockMode($config->getLockMode());
49 
50  $visibility = new PortableVisibilityConverter(
51  $config->getFileAccessPublic(),
52  $config->getFileAccessPrivate(),
53  $config->getDirectoryAccessPublic(),
54  $config->getDirectoryAccessPrivate(),
56  );
57 
58  $adapter = new LocalFilesystemAdapter(
59  $config->getRootPath(),
60  $visibility,
61  $config->getLockMode(),
63  );
64 
65  $filesystem = new \League\Flysystem\Filesystem($adapter);
66 
67  $fileAccess = new FlySystemFileAccess($filesystem);
68 
69  return new FilesystemFacade(
70  new FlySystemFileStreamAccess($filesystem),
71  $fileAccess,
72  new FlySystemDirectoryAccess($filesystem, $fileAccess)
73  );
74  }
75 
85  private function mapConfigLinkToLocalLinks(int $configLinkBehaviour): int
86  {
87  return match ($configLinkBehaviour) {
88  LocalConfig::DISALLOW_LINKS => LocalFilesystemAdapter::DISALLOW_LINKS,
89  LocalConfig::SKIP_LINKS => LocalFilesystemAdapter::SKIP_LINKS,
90  default => throw new \InvalidArgumentException(
91  "The supplied value \"$configLinkBehaviour\" is not a valid LocalConfig link behaviour constant."
92  ),
93  };
94  }
95 
108  private function validateFileLockMode(int $code): void
109  {
110  if ($code === LOCK_EX) {
111  return;
112  }
113  if ($code === LOCK_SH) {
114  return;
115  }
116  throw new \InvalidArgumentException(
117  "The supplied value \"$code\" is not a valid file lock mode please check your local file storage configurations."
118  );
119  }
120 }
Class ChatMainBarProvider .
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
mapConfigLinkToLocalLinks(int $configLinkBehaviour)
Maps a constant of the LocalConfig class into a constant of the Local class.
getInstance(LocalConfig $config)
Creates a new instance of the local filesystem adapter used by fly system.
This class is used to configure the local filesystem adapter.
Definition: LocalConfig.php:29
const PUBLIC_ACCESS
Public file visibility.
Definition: Visibility.php:34
const DISALLOW_LINKS
This is the default behaviour because links violate the root filesystem constraint.
Definition: LocalConfig.php:35
validateFileLockMode(int $code)
Checks if the supplied file lock mode is valid.
The filesystem facade is used internally to satisfy the Filesystem interface because the implementati...