Skip to content

Commit 5c210c8

Browse files
authored
Merge pull request #255 from Flowpack/neos-9
!!!FEATURE: Neos 9 compatibility
2 parents ea6abb6 + 7261937 commit 5c210c8

File tree

18 files changed

+504
-253
lines changed

18 files changed

+504
-253
lines changed

.github/workflows/tests.yml

Lines changed: 50 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,11 @@ jobs:
3636
- name: Setup PHP
3737
uses: shivammathur/setup-php@v2
3838
with:
39-
php-version: 8.1
39+
php-version: 8.2
40+
41+
- name: Add additional dependencies
42+
run: |
43+
composer require --no-update --no-interaction neos/contentgraph-doctrinedbaladapter:"~9.0.0"
4044
4145
- name: Cache dependencies
4246
uses: actions/cache@v3
@@ -47,13 +51,13 @@ jobs:
4751
- name: Install dependencies
4852
uses: php-actions/composer@v6
4953
with:
50-
php_version: 8.1
54+
php_version: 8.2
5155
version: 2
5256

5357
- name: PHPStan
5458
uses: php-actions/phpstan@v3
5559
with:
56-
php_version: 8.1
60+
php_version: 8.2
5761
version: 2.1.17
5862
command: analyse
5963
path: 'Classes/'
@@ -68,8 +72,22 @@ jobs:
6872
strategy:
6973
fail-fast: false
7074
matrix:
71-
php-versions: ['8.1']
72-
flow-versions: ['8.3']
75+
php-versions: ['8.2']
76+
flow-versions: ['9.0']
77+
78+
services:
79+
mariadb:
80+
# see https://mariadb.com/kb/en/mariadb-server-release-dates/
81+
# this should be a current release, e.g. the LTS version
82+
image: mariadb:10.8
83+
env:
84+
MYSQL_USER: neos
85+
MYSQL_PASSWORD: neos
86+
MYSQL_DATABASE: neos_functional_testing
87+
MYSQL_ROOT_PASSWORD: neos
88+
ports:
89+
- "3306:3306"
90+
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
7391

7492
steps:
7593
- uses: actions/checkout@v3
@@ -96,12 +114,11 @@ jobs:
96114
run: |
97115
git clone https://github.com/neos/flow-base-distribution.git -b ${{ matrix.flow-versions }} ${FLOW_FOLDER}
98116
cd ${FLOW_FOLDER}
99-
composer require --no-update --no-interaction flowpack/entity-usage:"^1.1"
100-
composer require --no-update --no-interaction flowpack/entity-usage-databasestorage:"^0.1"
101117
102118
git -C ../${{ env.PACKAGE_FOLDER }} checkout -b build
103119
composer config repositories.package '{ "type": "path", "url": "../${{ env.PACKAGE_FOLDER }}", "options": { "symlink": false } }'
104120
composer require --no-update --no-interaction flowpack/media-ui:"dev-build as dev-${PACKAGE_TARGET_VERSION}"
121+
composer require --no-update --no-interaction neos/contentgraph-doctrinedbaladapter:"~9.0.0"
105122
106123
- name: Composer Install
107124
run: |
@@ -113,11 +130,37 @@ jobs:
113130
cd ${FLOW_FOLDER}
114131
bin/phpunit --colors -c Build/BuildEssentials/PhpUnit/UnitTests.xml Packages/Application/Flowpack.Media.Ui/Tests/Unit/
115132
133+
- name: Setup Flow configuration
134+
run: |
135+
cd ${FLOW_FOLDER}
136+
rm -f Configuration/Testing/Settings.yaml
137+
cat <<EOF >> Configuration/Testing/Settings.yaml
138+
Neos:
139+
Flow:
140+
persistence:
141+
backendOptions:
142+
host: '127.0.0.1'
143+
driver: pdo_mysql
144+
user: 'neos'
145+
password: 'neos'
146+
dbname: 'neos_functional_testing'
147+
EOF
148+
116149
- name: Run Functional tests
117150
run: |
118151
cd ${FLOW_FOLDER}
119152
bin/phpunit --colors -c Build/BuildEssentials/PhpUnit/FunctionalTests.xml Packages/Application/Flowpack.Media.Ui/Tests/Functional/
120153
154+
- name: Show log on failure
155+
if: ${{ failure() }}
156+
run: |
157+
cd ${FLOW_PATH_ROOT}
158+
cat Data/Logs/System_Testing.log
159+
for file in Data/Logs/Exceptions/*; do
160+
echo $file
161+
cat $file
162+
done
163+
121164
js-unit-tests:
122165
runs-on: ubuntu-latest
123166

Classes/Domain/Model/AssetSource/NeosAssetProxyRepository.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ public function orderBy(array $orderings): void
111111
$this->assetRepository->setDefaultOrderings($orderings);
112112
}
113113

114-
public function filterByType(AssetTypeFilter $assetType = null): void
114+
public function filterByType(?AssetTypeFilter $assetType = null): void
115115
{
116116
$this->assetTypeFilter = (string)$assetType ?: 'All';
117117
$this->initializeObject();
@@ -126,7 +126,7 @@ public function filterByMediaType(string $mediaType): void
126126
* NOTE: This needs to be refactored to use an asset collection identifier instead of Media's domain model before
127127
* it can become a public API for other asset sources.
128128
*/
129-
public function filterByCollection(AssetCollection $assetCollection = null): void
129+
public function filterByCollection(?AssetCollection $assetCollection = null): void
130130
{
131131
$this->activeAssetCollection = $assetCollection;
132132
}

Classes/GraphQL/MediaApi.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -280,13 +280,12 @@ public function assetUsageCount(Types\AssetId $id, Types\AssetSourceId $assetSou
280280
#[Query]
281281
public function unusedAssets(int $limit = 20, int $offset = 0): Types\Assets
282282
{
283-
$assets = [];
284283
try {
285-
$assets = $this->usageDetailsService->getUnusedAssets($limit, $offset, Types\AssetSourceId::default());
284+
return $this->usageDetailsService->getUnusedAssets($limit, $offset, Types\AssetSourceId::default());
286285
} catch (MediaUiException $e) {
287286
$this->logger->error('Could not retrieve unused assets', ['exception' => $e]);
288287
}
289-
return Types\Assets::fromAssets($assets);
288+
return Types\Assets::empty();
290289
}
291290

292291
#[Description('Provides a list of changes to assets since a given timestamp')]

Classes/GraphQL/Types/AssetCollection.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,9 @@ private function __construct(
1717
public readonly ?AssetCollectionPath $path = null,
1818
) {
1919
}
20+
21+
public function equals(?AssetCollection $assetCollection): bool
22+
{
23+
return $assetCollection !== null && $this->id->equals($assetCollection->id);
24+
}
2025
}

Classes/GraphQL/Types/AssetCollectionId.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,9 @@ public function isUnassigned(): bool
3838
{
3939
return $this->value === self::UNASSIGNED;
4040
}
41+
42+
public function equals(?AssetCollectionId $id): bool
43+
{
44+
return $this->value === $id?->value;
45+
}
4146
}

Classes/GraphQL/Types/AssetCollections.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
#[ListBased(itemClassName: AssetCollection::class)]
1414
final class AssetCollections implements \IteratorAggregate
1515
{
16+
/**
17+
* @param AssetCollection[] $collections
18+
*/
1619
private function __construct(public readonly array $collections)
1720
{
1821
}

Classes/GraphQL/Types/AssetSourceId.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#[Description('Unique identifier of an Asset source (e.g. "neos")')]
1212
#[Flow\Proxy(false)]
1313
#[StringBased]
14-
final class AssetSourceId implements \JsonSerializable
14+
final class AssetSourceId implements \JsonSerializable, \Stringable
1515
{
1616
private function __construct(public readonly string $value)
1717
{
@@ -26,4 +26,14 @@ public static function default(): self
2626
{
2727
return new self('neos');
2828
}
29+
30+
public static function fromString(string $value): self
31+
{
32+
return new self($value);
33+
}
34+
35+
public function __toString(): string
36+
{
37+
return $this->value;
38+
}
2939
}

Classes/Service/AssetCollectionService.php

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,11 @@
99
use Flowpack\Media\Ui\Domain\Model\HierarchicalAssetCollectionInterface;
1010
use Flowpack\Media\Ui\GraphQL\Types;
1111
use Flowpack\Media\Ui\Utility\AssetCollectionUtility;
12-
use Neos\ContentRepository\Domain\Service\ContextFactoryInterface;
1312
use Neos\Flow\Annotations as Flow;
1413
use Neos\Flow\ObjectManagement\ObjectManagerInterface;
1514
use Neos\Media\Domain\Model\AssetCollection;
1615
use Neos\Media\Domain\Repository\AssetCollectionRepository;
17-
use Neos\Neos\Domain\Service\ContentContext;
16+
use Neos\Neos\Domain\Repository\DomainRepository;
1817

1918
#[Flow\Scope('singleton')]
2019
class AssetCollectionService
@@ -37,11 +36,8 @@ class AssetCollectionService
3736
#[Flow\Inject]
3837
protected AssetCollectionRepository $assetCollectionRepository;
3938

40-
/**
41-
* @var ContextFactoryInterface
42-
*/
4339
#[Flow\Inject]
44-
protected $contextFactory;
40+
protected DomainRepository $domainRepository;
4541

4642
/**
4743
* Queries the asset count for all asset collections once and caches the result.
@@ -98,11 +94,11 @@ public function updatePathForNestedAssetCollections(HierarchicalAssetCollectionI
9894
*/
9995
public function getDefaultCollectionForCurrentSite(): ?AssetCollection
10096
{
101-
/** @var ContentContext $context */
102-
$context = $this->contextFactory->create([
103-
'workspaceName' => 'live',
104-
]);
97+
$domain = $this->domainRepository->findOneByActiveRequest();
98+
if ($domain !== null) {
99+
return $domain->getSite()->getAssetCollection();
100+
}
105101

106-
return $context->getCurrentSite()?->getAssetCollection();
102+
return null;
107103
}
108104
}

0 commit comments

Comments
 (0)