Skip to content

Commit 9f99809

Browse files
authored
Merge pull request #39 from netgen/NGSTACK-995-upgrade-bundle-to-Ibexa-5
NGSTACK-995 upgrade bundle to ibexa 5
2 parents e8987dd + 1e95b15 commit 9f99809

File tree

14 files changed

+83
-83
lines changed

14 files changed

+83
-83
lines changed

.github/workflows/tests.yml

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,10 @@ jobs:
1515
strategy:
1616
fail-fast: false
1717
matrix:
18-
php: ['7.4', '8.0', '8.1']
19-
symfony: ['~5.4.0']
18+
php: ['8.3']
19+
symfony: ['~7.3.0']
2020
phpunit: ['phpunit.xml']
2121
deps: ['normal']
22-
include:
23-
- php: '7.4'
24-
symfony: '~5.4.0'
25-
phpunit: 'phpunit.xml'
26-
deps: 'low'
2722

2823
steps:
2924
- uses: actions/checkout@v2

bundle/Command/MigrateCommand.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
namespace Netgen\Bundle\EnhancedSelectionBundle\Command;
66

77
use Doctrine\DBAL\Connection;
8-
use Doctrine\DBAL\Driver\Result;
8+
use Doctrine\DBAL\Result;
99
use Netgen\Bundle\EnhancedSelectionBundle\Core\FieldType\EnhancedSelection\Type as EnhancedSelectionType;
1010
use Symfony\Component\Console\Command\Command;
1111
use Symfony\Component\Console\Input\InputInterface;
@@ -42,7 +42,7 @@ protected function initialize(InputInterface $input, OutputInterface $output): v
4242
$this->io = new SymfonyStyle($input, $output);
4343
}
4444

45-
protected function execute(InputInterface $input, OutputInterface $output): ?int
45+
protected function execute(InputInterface $input, OutputInterface $output): int
4646
{
4747
$statement = $this->getFields();
4848
$this->io->progressStart($statement->rowCount());
@@ -80,7 +80,7 @@ private function getFields(): Result
8080
)
8181
->setParameter('data_type_string', $this->typeIdentifier);
8282

83-
return $builder->execute();
83+
return $builder->executeQuery();
8484
}
8585

8686
private function resetFieldData(int $id, int $version): void
@@ -96,7 +96,7 @@ private function resetFieldData(int $id, int $version): void
9696
->setParameter('id', $id)
9797
->setParameter('version', $version);
9898

99-
$builder->execute();
99+
$builder->executeStatement();
100100
}
101101

102102
private function removeSelectionDataForField(int $id, int $version): void
@@ -111,7 +111,7 @@ private function removeSelectionDataForField(int $id, int $version): void
111111
->setParameter('id', $id)
112112
->setParameter('version', $version);
113113

114-
$builder->execute();
114+
$builder->executeStatement();
115115
}
116116

117117
private function createSelections(int $id, int $version, array $identifiers): void

bundle/Core/FieldType/EnhancedSelection/EnhancedSelectionStorage.php

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

1111
final class EnhancedSelectionStorage extends GatewayBasedStorage
1212
{
13-
public function storeFieldData(VersionInfo $versionInfo, Field $field, array $context): ?bool
13+
public function storeFieldData(VersionInfo $versionInfo, Field $field): ?bool
1414
{
1515
$this->gateway->deleteFieldData($versionInfo, [$field->id]);
1616
if (!empty($field->value->externalData)) {
@@ -20,12 +20,12 @@ public function storeFieldData(VersionInfo $versionInfo, Field $field, array $co
2020
return null;
2121
}
2222

23-
public function getFieldData(VersionInfo $versionInfo, Field $field, array $context): void
23+
public function getFieldData(VersionInfo $versionInfo, Field $field): void
2424
{
2525
$this->gateway->getFieldData($versionInfo, $field);
2626
}
2727

28-
public function deleteFieldData(VersionInfo $versionInfo, array $fieldIds, array $context): bool
28+
public function deleteFieldData(VersionInfo $versionInfo, array $fieldIds): bool
2929
{
3030
$this->gateway->deleteFieldData($versionInfo, $fieldIds);
3131

@@ -37,7 +37,7 @@ public function hasFieldData(): bool
3737
return true;
3838
}
3939

40-
public function getIndexData(VersionInfo $versionInfo, Field $field, array $context)
40+
public function getIndexData(VersionInfo $versionInfo, Field $field): bool
4141
{
4242
return false;
4343
}

bundle/Core/FieldType/EnhancedSelection/EnhancedSelectionStorage/Gateway/DoctrineStorage.php

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace Netgen\Bundle\EnhancedSelectionBundle\Core\FieldType\EnhancedSelection\EnhancedSelectionStorage\Gateway;
66

7+
use Doctrine\DBAL\ArrayParameterType;
78
use Doctrine\DBAL\Connection;
89
use Doctrine\DBAL\Types\Types;
910
use Ibexa\Contracts\Core\Persistence\Content\Field;
@@ -34,11 +35,11 @@ public function storeFieldData(VersionInfo $versionInfo, Field $field): void
3435
'identifier' => ':identifier',
3536
]
3637
)
37-
->setParameter(':contentobject_attribute_id', $field->id, Types::INTEGER)
38-
->setParameter(':contentobject_attribute_version', $versionInfo->versionNo, Types::INTEGER)
39-
->setParameter(':identifier', $identifier, Types::STRING);
38+
->setParameter('contentobject_attribute_id', $field->id, Types::INTEGER)
39+
->setParameter('contentobject_attribute_version', $versionInfo->versionNo, Types::INTEGER)
40+
->setParameter('identifier', $identifier, Types::STRING);
4041

41-
$insertQuery->execute();
42+
$insertQuery->executeStatement();
4243
}
4344
}
4445

@@ -54,14 +55,14 @@ public function deleteFieldData(VersionInfo $versionInfo, array $fieldIds): void
5455
->delete($this->connection->quoteIdentifier('sckenhancedselection'))
5556
->where(
5657
$query->expr()->and(
57-
$query->expr()->in('contentobject_attribute_id', [':contentobject_attribute_id']),
58+
$query->expr()->in('contentobject_attribute_id', ':contentobject_attribute_id'),
5859
$query->expr()->eq('contentobject_attribute_version', ':contentobject_attribute_version')
5960
)
6061
)
61-
->setParameter(':contentobject_attribute_id', $fieldIds, Connection::PARAM_INT_ARRAY)
62-
->setParameter(':contentobject_attribute_version', $versionInfo->versionNo, Types::INTEGER);
62+
->setParameter('contentobject_attribute_id', $fieldIds, ArrayParameterType::INTEGER)
63+
->setParameter('contentobject_attribute_version', $versionInfo->versionNo, Types::INTEGER);
6364

64-
$query->execute();
65+
$query->executeStatement();
6566
}
6667

6768
/**
@@ -81,12 +82,10 @@ private function loadFieldData(int $fieldId, int $versionNo): array
8182
$query->expr()->eq('contentobject_attribute_version', ':contentobject_attribute_version')
8283
)
8384
)
84-
->setParameter(':contentobject_attribute_id', $fieldId, Types::INTEGER)
85-
->setParameter(':contentobject_attribute_version', $versionNo, Types::INTEGER);
85+
->setParameter('contentobject_attribute_id', $fieldId, Types::INTEGER)
86+
->setParameter('contentobject_attribute_version', $versionNo, Types::INTEGER);
8687

87-
$statement = $query->execute();
88-
89-
$rows = $statement->fetchAllAssociative();
88+
$rows = $query->executeQuery()->fetchAllAssociative();
9089

9190
return array_map(
9291
static fn (array $row): string => $row['identifier'],

bundle/Core/FieldType/EnhancedSelection/Type.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -316,9 +316,9 @@ public function validateFieldSettings($fieldSettings): array
316316

317317
if ($emptyCount > ($fieldSettings['isMultiple'] ? 0 : 1)) {
318318
$validationErrors[] = new ValidationError(
319-
$fieldSettings['isMultiple'] ?
320-
"'%setting%' setting value item's 'identifier' property must have a value" :
321-
"'%setting%' setting value item's 'identifier' property must have only a single empty value",
319+
$fieldSettings['isMultiple']
320+
? "'%setting%' setting value item's 'identifier' property must have a value"
321+
: "'%setting%' setting value item's 'identifier' property must have only a single empty value",
322322
null,
323323
[
324324
'%setting%' => $name,

bundle/Core/Search/Legacy/Content/Common/Gateway/CriterionHandler/EnhancedSelection.php

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,28 @@
66

77
use Doctrine\DBAL\Connection;
88
use Doctrine\DBAL\Query\QueryBuilder;
9-
use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion;
9+
use Ibexa\Contracts\Core\Repository\Values\Content\Query\CriterionInterface;
1010
use Ibexa\Core\Base\Exceptions\InvalidArgumentException;
1111
use Ibexa\Core\Search\Legacy\Content\Common\Gateway\CriteriaConverter;
1212
use Ibexa\Core\Search\Legacy\Content\Common\Gateway\CriterionHandler\FieldBase;
1313
use Netgen\Bundle\EnhancedSelectionBundle\API\Repository\Values\Content\Query\Criterion\EnhancedSelection as EnhancedSelectionCriterion;
1414

1515
final class EnhancedSelection extends FieldBase
1616
{
17-
public function accept(Criterion $criterion): bool
17+
public function accept(CriterionInterface $criterion): bool
1818
{
1919
return $criterion instanceof EnhancedSelectionCriterion;
2020
}
2121

22-
public function handle(CriteriaConverter $converter, QueryBuilder $queryBuilder, Criterion $criterion, array $languageSettings): string
23-
{
22+
/**
23+
* @param \Netgen\Bundle\EnhancedSelectionBundle\API\Repository\Values\Content\Query\Criterion\EnhancedSelection $criterion
24+
*/
25+
public function handle(
26+
CriteriaConverter $converter,
27+
QueryBuilder $queryBuilder,
28+
CriterionInterface $criterion,
29+
array $languageSettings,
30+
): string {
2431
$fieldDefinitionIds = $this->getFieldDefinitionIds($criterion->target);
2532

2633
$subSelect = $this->connection->createQueryBuilder();

bundle/Core/Search/Solr/Query/CriterionVisitor/EnhancedSelection.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
namespace Netgen\Bundle\EnhancedSelectionBundle\Core\Search\Solr\Query\CriterionVisitor;
66

7-
use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion;
7+
use Ibexa\Contracts\Core\Repository\Values\Content\Query\CriterionInterface;
88
use Ibexa\Contracts\Solr\Query\CriterionVisitor;
99
use Ibexa\Core\Base\Exceptions\InvalidArgumentException;
1010
use Ibexa\Solr\Query\Common\CriterionVisitor\Field;
@@ -14,12 +14,17 @@
1414

1515
final class EnhancedSelection extends Field
1616
{
17-
public function canVisit(Criterion $criterion): bool
17+
public function canVisit(CriterionInterface $criterion): bool
1818
{
1919
return $criterion instanceof EnhancedSelectionCriterion;
2020
}
2121

22-
public function visit(Criterion $criterion, ?CriterionVisitor $subVisitor = null): string
22+
/**
23+
* @param \Netgen\Bundle\EnhancedSelectionBundle\API\Repository\Values\Content\Query\Criterion\EnhancedSelection $criterion
24+
*
25+
* @throws \Ibexa\Core\Base\Exceptions\InvalidArgumentException
26+
*/
27+
public function visit(CriterionInterface $criterion, ?CriterionVisitor $subVisitor = null): string
2328
{
2429
$searchFields = $this->getSearchFields($criterion);
2530

bundle/Form/Type/FieldType/FieldValueTransformer.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@ public function reverseTransform($value): Value
4747
return $this->fieldType->getEmptyValue();
4848
}
4949

50-
$hash = is_array($value['identifiers']) ?
51-
$value['identifiers'] :
52-
[$value['identifiers']];
50+
$hash = is_array($value['identifiers'])
51+
? $value['identifiers']
52+
: [$value['identifiers']];
5353

5454
return $this->fieldType->fromHash($hash);
5555
}

composer.json

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,15 @@
1616
}
1717
],
1818
"require": {
19-
"ibexa/core": "^4.0",
20-
"ibexa/content-forms": "^4.0",
19+
"ibexa/core": "^5.0",
20+
"ibexa/content-forms": "^5.0",
2121
"twig/twig": "^3.0"
2222
},
2323
"require-dev": {
24-
"phpunit/phpunit": "^9.0",
25-
"netgen/ibexa-forms-bundle": "^4.0",
26-
"friendsofphp/php-cs-fixer": "^3.3"
24+
"phpunit/phpunit": "^12.0",
25+
"netgen/ibexa-forms-bundle": "^5.0",
26+
"friendsofphp/php-cs-fixer": "^3.3",
27+
"ibexa/solr": "^5.0"
2728
},
2829
"minimum-stability": "dev",
2930
"prefer-stable": true,

phpunit.xml

Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,36 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<phpunit bootstrap="vendor/autoload.php"
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
bootstrap="vendor/autoload.php"
34
backupGlobals="false"
4-
backupStaticAttributes="false"
5-
convertErrorsToExceptions="true"
6-
convertNoticesToExceptions="true"
7-
convertWarningsToExceptions="true"
85
colors="true"
9-
verbose="true"
106
processIsolation="false"
117
stopOnFailure="false"
128
beStrictAboutTestsThatDoNotTestAnything="false"
9+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/12.4/phpunit.xsd"
10+
cacheDirectory=".phpunit.cache"
11+
backupStaticProperties="false"
1312
>
1413
<testsuites>
1514
<testsuite name="Netgen\EnhancedSelectionBundle\Tests">
1615
<directory>tests</directory>
1716
</testsuite>
1817
</testsuites>
19-
<filter>
20-
<whitelist>
21-
<directory suffix=".php">bundle</directory>
22-
<exclude>
23-
<directory>bundle/DependencyInjection</directory>
24-
<directory>bundle/Resources</directory>
25-
<directory>vendor</directory>
26-
<file>bundle/Core/Search/Legacy/Content/Common/Gateway/CriterionHandler/EnhancedSelection.php</file>
27-
<file>bundle/Core/FieldType/EnhancedSelection/SearchField.php</file>
28-
<file>bundle/NetgenEnhancedSelectionBundle.php</file>
29-
</exclude>
30-
</whitelist>
31-
</filter>
18+
3219
<logging>
33-
<log type="junit" target="build/report.junit.xml"/>
34-
<log type="coverage-html" target="build/coverage"/>
35-
<log type="coverage-text" target="build/coverage.txt"/>
36-
<log type="coverage-clover" target="build/logs/clover.xml"/>
20+
<junit outputFile="build/report.junit.xml"/>
3721
</logging>
22+
23+
<source>
24+
<include>
25+
<directory suffix=".php">bundle</directory>
26+
</include>
27+
<exclude>
28+
<directory>bundle/DependencyInjection</directory>
29+
<directory>bundle/Resources</directory>
30+
<directory>vendor</directory>
31+
<file>bundle/Core/Search/Legacy/Content/Common/Gateway/CriterionHandler/EnhancedSelection.php</file>
32+
<file>bundle/Core/FieldType/EnhancedSelection/SearchField.php</file>
33+
<file>bundle/NetgenEnhancedSelectionBundle.php</file>
34+
</exclude>
35+
</source>
3836
</phpunit>

0 commit comments

Comments
 (0)