Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IBX-1439: Upgraded codebase to rely on Flysystem v2 #171

Merged
merged 16 commits into from
Jan 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"symfony/mime": "^5.3.0",
"symfony/translation": "^5.3.0",
"symfony/yaml": "^5.3.0",
"symfony/polyfill-php80": "^1.27",
"symfony/security-core": "^5.3.0",
"symfony/security-http": "^5.3.0",
"symfony/security-bundle": "^5.3.0",
Expand All @@ -46,7 +47,8 @@
"doctrine/orm": "^2.7",
"doctrine/doctrine-bundle": "^2.0",
"liip/imagine-bundle": "^2.3",
"oneup/flysystem-bundle": "^3.4",
"oneup/flysystem-bundle": "^4.4.2",
"league/flysystem-memory": "^2.0.6",
"friendsofsymfony/http-cache-bundle": "^2.8",
"sensio/framework-extra-bundle": "^6.1",
"jms/translation-bundle": "^1.5",
Expand All @@ -62,7 +64,6 @@
"behat/behat": "^3.6.1",
"jenner/simple_fork": "^1.2",
"friends-of-behat/mink-extension": "^2.4",
"league/flysystem-memory": "^1.0",
"ibexa/ci-scripts": "^0.2@dev",
"ibexa/code-style": "^1.0",
"phpunit/phpunit": "^8.2",
Expand Down
5 changes: 4 additions & 1 deletion src/bundle/Core/Resources/config/default_settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -256,8 +256,11 @@ parameters:
##
ibexa.orm.entity_mappings: []

# fallback for existing project configuration, should be overridden
dfs_nfs_path: '%ibexa.io.dir.storage%'

ibexa.io.nfs.adapter.config:
root: './'
root: '%dfs_nfs_path%'
path: '$var_dir$/$storage_dir$/'
writeFlags: ~
linkHandling: ~
Expand Down
51 changes: 0 additions & 51 deletions src/bundle/IO/Flysystem/Adapter/SiteAccessAwareLocalAdapter.php

This file was deleted.

14 changes: 0 additions & 14 deletions src/bundle/IO/Resources/config/io.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,20 +97,6 @@ services:
class: Ibexa\Bundle\IO\ApiLoader\HandlerRegistry

# Inject the siteaccess config into a few io services
Ibexa\Core\IO\Adapter\LocalAdapter:
autoconfigure: true
arguments:
- '@Ibexa\Core\IO\IOConfigProvider'
- '@ibexa.config.resolver'

Ibexa\Bundle\IO\Flysystem\Adapter\SiteAccessAwareLocalAdapter:
arguments:
$configProcessor: '@Ibexa\Contracts\Core\SiteAccess\ConfigProcessor'
$config: '%ibexa.io.nfs.adapter.config%'

ibexa.io.nfs.adapter.site_access_aware:
alias: Ibexa\Bundle\IO\Flysystem\Adapter\SiteAccessAwareLocalAdapter

Ibexa\Core\IO\UrlDecorator\AbsolutePrefix:
class: Ibexa\Core\IO\UrlDecorator\AbsolutePrefix
arguments:
Expand Down
12 changes: 7 additions & 5 deletions src/contracts/Test/IbexaTestKernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@
use Ibexa\Contracts\Core\Persistence\TransactionHandler;
use Ibexa\Contracts\Core\Repository;
use Ibexa\Contracts\Core\Test\Persistence\Fixture\YamlFixture;
use Ibexa\Core\IO\Adapter\LocalAdapter;
use JMS\TranslationBundle\JMSTranslationBundle;
use League\Flysystem\Memory\MemoryAdapter;
use League\Flysystem\InMemory\InMemoryFilesystemAdapter;
use Liip\ImagineBundle\LiipImagineBundle;
use LogicException;
use Psr\Log\NullLogger;
Expand Down Expand Up @@ -209,15 +208,18 @@ private static function getResourcesPath(): string

private static function prepareIOServices(ContainerBuilder $container): void
{
if (!class_exists(MemoryAdapter::class)) {
if (!class_exists(InMemoryFilesystemAdapter::class)) {
throw new LogicException(sprintf(
'Missing %s class. Ensure that %s package is installed as a dev dependency',
MemoryAdapter::class,
InMemoryFilesystemAdapter::class,
'league/flysystem-memory',
));
}

$container->setDefinition(LocalAdapter::class, new Definition(MemoryAdapter::class));
$container->setDefinition(
'ibexa.core.io.flysystem.adapter.site_access_aware',
new Definition(InMemoryFilesystemAdapter::class)
);
}

private static function createPublicAliasesForServicesUnderTest(ContainerBuilder $container): void
Expand Down
71 changes: 0 additions & 71 deletions src/lib/IO/Adapter/LocalAdapter.php

This file was deleted.

12 changes: 7 additions & 5 deletions src/lib/IO/FilePathNormalizer/Flysystem.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,20 @@

use Ibexa\Core\IO\FilePathNormalizerInterface;
use Ibexa\Core\Persistence\Legacy\Content\UrlAlias\SlugConverter;
use League\Flysystem\Util;
use League\Flysystem\PathNormalizer;

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

/** @var \Ibexa\Core\Persistence\Legacy\Content\UrlAlias\SlugConverter */
private $slugConverter;
private SlugConverter $slugConverter;

public function __construct(SlugConverter $slugConverter)
private PathNormalizer $pathNormalizer;

public function __construct(SlugConverter $slugConverter, PathNormalizer $pathNormalizer)
{
$this->slugConverter = $slugConverter;
$this->pathNormalizer = $pathNormalizer;
}

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

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

return Util::normalizePath($filePath);
return $this->pathNormalizer->normalizePath($filePath);
}
}

Expand Down
Loading