Skip to content

Commit 74ddacf

Browse files
authored
Merge pull request #14 from netgen/NGSTACK-1000-upgrade-bundle-to-Ibexa-v5
NGSTACK-1000 upgrade bundle to ibexa v5
2 parents dd3db6a + c5c34d2 commit 74ddacf

File tree

18 files changed

+115
-144
lines changed

18 files changed

+115
-144
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: ['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: '8.1'
24-
symfony: '~5.4.0'
25-
phpunit: 'phpunit.xml'
26-
deps: 'low'
2722

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

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ vendor
44
composer.lock
55
.idea
66
build
7+
.phpunit.cache

.php-cs-fixer.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
'single_line_comment_style' => false,
3030
'trailing_comma_in_multiline' => ['elements' => ['arrays', 'arguments', 'match', 'parameters']],
3131
'yoda_style' => false,
32+
'fully_qualified_strict_types' => false,
3233

3334
// Additional rules
3435
'date_time_immutable' => true,
@@ -39,7 +40,7 @@
3940
'import_functions' => true,
4041
],
4142
'heredoc_indentation' => ['indentation' => 'same_as_start'],
42-
'mb_str_functions' => true,
43+
// 'mb_str_functions' => true,
4344
'native_constant_invocation' => true,
4445
'nullable_type_declaration_for_default_null_value' => true,
4546
'static_lambda' => true,

bundle/Handler/FieldType/Handler.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,9 @@
1515

1616
abstract class Handler extends BaseHandler
1717
{
18-
protected FieldHelper $fieldHelper;
19-
20-
public function __construct(FieldHelper $fieldHelper)
21-
{
22-
$this->fieldHelper = $fieldHelper;
23-
}
18+
public function __construct(
19+
protected FieldHelper $fieldHelper,
20+
) {}
2421

2522
public function getMetaTags(string $tagName, array $params = []): array
2623
{

bundle/Handler/FieldType/Image.php

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,27 +17,19 @@
1717
use Symfony\Component\HttpFoundation\RequestStack;
1818

1919
use function ltrim;
20-
use function mb_strpos;
20+
use function str_starts_with;
2121

2222
final class Image extends Handler
2323
{
24-
private VariationHandler $imageVariationService;
25-
26-
private RequestStack $requestStack;
27-
28-
private LoggerInterface $logger;
29-
3024
public function __construct(
3125
FieldHelper $fieldHelper,
32-
VariationHandler $imageVariationService,
33-
RequestStack $requestStack,
34-
?LoggerInterface $logger = null,
26+
private readonly VariationHandler $imageVariationService,
27+
private readonly RequestStack $requestStack,
28+
private ?LoggerInterface $logger = null,
3529
) {
3630
parent::__construct($fieldHelper);
3731

38-
$this->imageVariationService = $imageVariationService;
39-
$this->requestStack = $requestStack;
40-
$this->logger = $logger ?? new NullLogger();
32+
$this->logger ??= new NullLogger();
4133
}
4234

4335
protected function getFieldValue(Field $field, string $tagName, array $params = []): string
@@ -48,7 +40,7 @@ protected function getFieldValue(Field $field, string $tagName, array $params =
4840
try {
4941
$variationUri = $this->imageVariationService->getVariation($field, $this->content->getVersionInfo(), $variationName)->uri;
5042

51-
if (mb_strpos($variationUri, '/') === 0 && ($request = $this->requestStack->getCurrentRequest()) !== null) {
43+
if (str_starts_with($variationUri, '/') && ($request = $this->requestStack->getCurrentRequest()) !== null) {
5244
$variationUri = $request->getUriForPath('/' . ltrim($variationUri, '/'));
5345
}
5446

bundle/Handler/Literal/CanonicalUrl.php

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,10 @@
1515

1616
final class CanonicalUrl implements HandlerInterface
1717
{
18-
private RequestStack $requestStack;
19-
20-
private UrlGeneratorInterface $urlGenerator;
21-
22-
public function __construct(RequestStack $requestStack, UrlGeneratorInterface $urlGenerator)
23-
{
24-
$this->requestStack = $requestStack;
25-
$this->urlGenerator = $urlGenerator;
26-
}
18+
public function __construct(
19+
private readonly RequestStack $requestStack,
20+
private readonly UrlGeneratorInterface $urlGenerator,
21+
) {}
2722

2823
public function getMetaTags($tagName, array $params = []): array
2924
{

bundle/Handler/Literal/Url.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,9 @@
1515

1616
final class Url implements HandlerInterface
1717
{
18-
private RequestStack $requestStack;
19-
20-
public function __construct(RequestStack $requestStack)
21-
{
22-
$this->requestStack = $requestStack;
23-
}
18+
public function __construct(
19+
private readonly RequestStack $requestStack,
20+
) {}
2421

2522
public function getMetaTags(string $tagName, array $params = []): array
2623
{

bundle/MetaTag/Collector.php

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -16,31 +16,24 @@
1616

1717
final class Collector implements CollectorInterface
1818
{
19-
private Registry $metaTagHandlers;
20-
21-
private ContentTypeService $contentTypeService;
22-
23-
private ConfigResolverInterface $configResolver;
24-
25-
public function __construct(Registry $metaTagHandlers, ContentTypeService $contentTypeService, ConfigResolverInterface $configResolver)
26-
{
27-
$this->metaTagHandlers = $metaTagHandlers;
28-
$this->contentTypeService = $contentTypeService;
29-
$this->configResolver = $configResolver;
30-
}
19+
public function __construct(
20+
private readonly Registry $metaTagHandlers,
21+
private readonly ContentTypeService $contentTypeService,
22+
private readonly ConfigResolverInterface $configResolver,
23+
) {}
3124

3225
public function collect(Content $content): array
3326
{
3427
$metaTags = [];
3528

36-
$allHandlers = $this->configResolver->hasParameter('global_handlers', 'netgen_open_graph') ?
37-
$this->configResolver->getParameter('global_handlers', 'netgen_open_graph') :
38-
[];
29+
$allHandlers = $this->configResolver->hasParameter('global_handlers', 'netgen_open_graph')
30+
? $this->configResolver->getParameter('global_handlers', 'netgen_open_graph')
31+
: [];
3932

4033
$contentType = $this->contentTypeService->loadContentType($content->contentInfo->contentTypeId);
41-
$contentTypeHandlers = $this->configResolver->hasParameter('content_type_handlers', 'netgen_open_graph') ?
42-
$this->configResolver->getParameter('content_type_handlers', 'netgen_open_graph') :
43-
[];
34+
$contentTypeHandlers = $this->configResolver->hasParameter('content_type_handlers', 'netgen_open_graph')
35+
? $this->configResolver->getParameter('content_type_handlers', 'netgen_open_graph')
36+
: [];
4437

4538
if (isset($contentTypeHandlers[$contentType->identifier])) {
4639
$allHandlers = array_merge(
@@ -61,8 +54,8 @@ public function collect(Content $content): array
6154
foreach ($newMetaTags as $metaTag) {
6255
if (!$metaTag instanceof Item) {
6356
throw new LogicException(
64-
'\'' . $handler['handler'] . '\' handler returned wrong value.' .
65-
' Expected \'Netgen\Bundle\OpenGraphBundle\MetaTag\Item\', got \'' . get_class($metaTag) . '\'.',
57+
'\'' . $handler['handler'] . '\' handler returned wrong value.'
58+
. ' Expected \'Netgen\Bundle\OpenGraphBundle\MetaTag\Item\', got \'' . get_class($metaTag) . '\'.',
6659
);
6760
}
6861

bundle/MetaTag/Item.php

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,10 @@
66

77
final class Item
88
{
9-
private string $tagName;
10-
11-
private string $tagValue;
12-
13-
public function __construct(string $tagName, string $tagValue)
14-
{
15-
$this->tagName = $tagName;
16-
$this->tagValue = $tagValue;
17-
}
9+
public function __construct(
10+
private readonly string $tagName,
11+
private readonly string $tagValue,
12+
) {}
1813

1914
/**
2015
* Returns tag name.

bundle/Templating/Twig/Extension/NetgenOpenGraphRuntime.php

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,26 +13,18 @@
1313

1414
final class NetgenOpenGraphRuntime
1515
{
16-
private CollectorInterface $tagCollector;
17-
18-
private RendererInterface $tagRenderer;
19-
20-
private LoggerInterface $logger;
21-
2216
private bool $throwExceptions = true;
2317

2418
public function __construct(
25-
CollectorInterface $tagCollector,
26-
RendererInterface $tagRenderer,
27-
?LoggerInterface $logger = null,
19+
private readonly CollectorInterface $tagCollector,
20+
private readonly RendererInterface $tagRenderer,
21+
private ?LoggerInterface $logger = null,
2822
) {
29-
$this->tagCollector = $tagCollector;
30-
$this->tagRenderer = $tagRenderer;
31-
$this->logger = $logger ?? new NullLogger();
23+
$this->logger ??= new NullLogger();
3224
}
3325

3426
/**
35-
* Sets the flag that determines if the exceptions will thrown instead of logged.
27+
* Sets the flag that determines if the exceptions will be thrown instead of logged.
3628
*/
3729
public function setThrowExceptions(bool $throwExceptions = true): void
3830
{

0 commit comments

Comments
 (0)