Skip to content

Commit 7d76881

Browse files
alongoszkonradobozamikadamczykSteveb-padamwojs
authored
IBX-1439: Upgraded codebase to rely on Flysystem v2 (#171)
For more details see https://issues.ibexa.co/browse/IBX-1439 and #171 * Bumped Flysystem dependencies to rely on Flysystem v2 * Moved league/flysystem-memory to require section * Upgraded codebase to use Flysystem v2 * Dropped obsolete test for file overwrite which now works OOTB * Implemented SiteAccess-aware Flysystem v2 integration (proxying Adapter) * Fixed production values of ibexa.io storage dir settings * Added test coverage for the new Flysystem v2 integration & aligned other tests with the changes Co-authored-by: Konrad Oboza <konradoboza@users.noreply.github.com> Co-Authored-By: Mikolaj Adamczyk <mikadamczyk@users.noreply.github.com> Co-Authored-By: Paweł Niedzielski <Steveb-p@users.noreply.github.com> Co-Authored-By: Adam Wójs <adamwojs@users.noreply.github.com>
1 parent 6572edb commit 7d76881

36 files changed

+1769
-443
lines changed

composer.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
"symfony/mime": "^5.3.0",
2828
"symfony/translation": "^5.3.0",
2929
"symfony/yaml": "^5.3.0",
30+
"symfony/polyfill-php80": "^1.27",
3031
"symfony/security-core": "^5.3.0",
3132
"symfony/security-http": "^5.3.0",
3233
"symfony/security-bundle": "^5.3.0",
@@ -46,7 +47,8 @@
4647
"doctrine/orm": "^2.7",
4748
"doctrine/doctrine-bundle": "^2.0",
4849
"liip/imagine-bundle": "^2.3",
49-
"oneup/flysystem-bundle": "^3.4",
50+
"oneup/flysystem-bundle": "^4.4.2",
51+
"league/flysystem-memory": "^2.0.6",
5052
"friendsofsymfony/http-cache-bundle": "^2.8",
5153
"sensio/framework-extra-bundle": "^6.1",
5254
"jms/translation-bundle": "^1.5",
@@ -62,7 +64,6 @@
6264
"behat/behat": "^3.6.1",
6365
"jenner/simple_fork": "^1.2",
6466
"friends-of-behat/mink-extension": "^2.4",
65-
"league/flysystem-memory": "^1.0",
6667
"ibexa/ci-scripts": "^0.2@dev",
6768
"ibexa/code-style": "^1.0",
6869
"phpunit/phpunit": "^8.2",

src/bundle/Core/Resources/config/default_settings.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,8 +259,11 @@ parameters:
259259
##
260260
ibexa.orm.entity_mappings: []
261261

262+
# fallback for existing project configuration, should be overridden
263+
dfs_nfs_path: '%ibexa.io.dir.storage%'
264+
262265
ibexa.io.nfs.adapter.config:
263-
root: './'
266+
root: '%dfs_nfs_path%'
264267
path: '$var_dir$/$storage_dir$/'
265268
writeFlags: ~
266269
linkHandling: ~

src/bundle/IO/Flysystem/Adapter/SiteAccessAwareLocalAdapter.php

Lines changed: 0 additions & 51 deletions
This file was deleted.

src/bundle/IO/Resources/config/io.yml

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -97,20 +97,6 @@ services:
9797
class: Ibexa\Bundle\IO\ApiLoader\HandlerRegistry
9898

9999
# Inject the siteaccess config into a few io services
100-
Ibexa\Core\IO\Adapter\LocalAdapter:
101-
autoconfigure: true
102-
arguments:
103-
- '@Ibexa\Core\IO\IOConfigProvider'
104-
- '@ibexa.config.resolver'
105-
106-
Ibexa\Bundle\IO\Flysystem\Adapter\SiteAccessAwareLocalAdapter:
107-
arguments:
108-
$configProcessor: '@Ibexa\Contracts\Core\SiteAccess\ConfigProcessor'
109-
$config: '%ibexa.io.nfs.adapter.config%'
110-
111-
ibexa.io.nfs.adapter.site_access_aware:
112-
alias: Ibexa\Bundle\IO\Flysystem\Adapter\SiteAccessAwareLocalAdapter
113-
114100
Ibexa\Core\IO\UrlDecorator\AbsolutePrefix:
115101
class: Ibexa\Core\IO\UrlDecorator\AbsolutePrefix
116102
arguments:

src/contracts/Test/IbexaTestKernel.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,8 @@
1616
use Ibexa\Contracts\Core\Persistence\TransactionHandler;
1717
use Ibexa\Contracts\Core\Repository;
1818
use Ibexa\Contracts\Core\Test\Persistence\Fixture\YamlFixture;
19-
use Ibexa\Core\IO\Adapter\LocalAdapter;
2019
use JMS\TranslationBundle\JMSTranslationBundle;
21-
use League\Flysystem\Memory\MemoryAdapter;
20+
use League\Flysystem\InMemory\InMemoryFilesystemAdapter;
2221
use Liip\ImagineBundle\LiipImagineBundle;
2322
use LogicException;
2423
use Psr\Log\NullLogger;
@@ -209,15 +208,18 @@ private static function getResourcesPath(): string
209208

210209
private static function prepareIOServices(ContainerBuilder $container): void
211210
{
212-
if (!class_exists(MemoryAdapter::class)) {
211+
if (!class_exists(InMemoryFilesystemAdapter::class)) {
213212
throw new LogicException(sprintf(
214213
'Missing %s class. Ensure that %s package is installed as a dev dependency',
215-
MemoryAdapter::class,
214+
InMemoryFilesystemAdapter::class,
216215
'league/flysystem-memory',
217216
));
218217
}
219218

220-
$container->setDefinition(LocalAdapter::class, new Definition(MemoryAdapter::class));
219+
$container->setDefinition(
220+
'ibexa.core.io.flysystem.adapter.site_access_aware',
221+
new Definition(InMemoryFilesystemAdapter::class)
222+
);
221223
}
222224

223225
private static function createPublicAliasesForServicesUnderTest(ContainerBuilder $container): void

src/lib/IO/Adapter/LocalAdapter.php

Lines changed: 0 additions & 71 deletions
This file was deleted.

src/lib/IO/FilePathNormalizer/Flysystem.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,20 @@
1010

1111
use Ibexa\Core\IO\FilePathNormalizerInterface;
1212
use Ibexa\Core\Persistence\Legacy\Content\UrlAlias\SlugConverter;
13-
use League\Flysystem\Util;
13+
use League\Flysystem\PathNormalizer;
1414

1515
final class Flysystem implements FilePathNormalizerInterface
1616
{
1717
private const HASH_PATTERN = '/^[0-9a-f]{12}-/';
1818

19-
/** @var \Ibexa\Core\Persistence\Legacy\Content\UrlAlias\SlugConverter */
20-
private $slugConverter;
19+
private SlugConverter $slugConverter;
2120

22-
public function __construct(SlugConverter $slugConverter)
21+
private PathNormalizer $pathNormalizer;
22+
23+
public function __construct(SlugConverter $slugConverter, PathNormalizer $pathNormalizer)
2324
{
2425
$this->slugConverter = $slugConverter;
26+
$this->pathNormalizer = $pathNormalizer;
2527
}
2628

2729
public function normalizePath(string $filePath, bool $doHash = true): string
@@ -37,7 +39,7 @@ public function normalizePath(string $filePath, bool $doHash = true): string
3739

3840
$filePath = $directory . \DIRECTORY_SEPARATOR . $hash . $fileName;
3941

40-
return Util::normalizePath($filePath);
42+
return $this->pathNormalizer->normalizePath($filePath);
4143
}
4244
}
4345

0 commit comments

Comments
 (0)