Skip to content

Commit 23c74de

Browse files
committed
Added support for laminas/laminas-servicemanager:4.x
Signed-off-by: alexmerlin <alex.merlin.1985@gmail.com>
1 parent 18575eb commit 23c74de

10 files changed

Lines changed: 55 additions & 31 deletions

File tree

.laminas-ci.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"ignore_php_platform_requirements": {
3+
"8.4": true
4+
},
5+
"backwardCompatibilityCheck": true
6+
}

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@
1111
[![Build Static](https://github.com/dotkernel/dot-navigation/actions/workflows/static-analysis.yml/badge.svg?branch=3.0)](https://github.com/dotkernel/dot-navigation/actions/workflows/static-analysis.yml)
1212
[![codecov](https://codecov.io/gh/dotkernel/dot-navigation/graph/badge.svg?token=AI9WFYDDX9)](https://codecov.io/gh/dotkernel/dot-navigation)
1313

14-
[![SymfonyInsight](https://insight.symfony.com/projects/68b7c728-4cc9-40ac-a3be-cf17f9b2eaf1/big.svg)](https://insight.symfony.com/projects/68b7c728-4cc9-40ac-a3be-cf17f9b2eaf1)
15-
1614
Allows you to easily define and parse menus inside templates, configuration based approach.
1715

1816
## Installation
1917

2018
Run
2119

22-
composer require dotkernel/dot-navigation
20+
```shell
21+
composer require dotkernel/dot-navigation
22+
```
2323

2424
Merge `ConfigProvider` to your application's configuration.
2525

composer.json

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "dotkernel/dot-navigation",
33
"type": "library",
4-
"description": "DotKernel navigation component",
4+
"description": "Dotkernel navigation component",
55
"license": "MIT",
66
"homepage": "https://github.com/dotkernel/dot-navigation",
77
"keywords": [
@@ -13,7 +13,7 @@
1313
],
1414
"authors": [
1515
{
16-
"name": "DotKernel Team",
16+
"name": "Dotkernel Team",
1717
"email": "team@dotkernel.com"
1818
}
1919
],
@@ -24,17 +24,17 @@
2424
}
2525
},
2626
"require": {
27-
"php": "~8.1.0 || ~8.2.0 || ~8.3.0",
27+
"php": "~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0",
2828
"dotkernel/dot-authorization": "^3.4.1",
29-
"dotkernel/dot-helpers": "^3.5.1",
29+
"dotkernel/dot-helpers": "^3.7.0",
3030
"laminas/laminas-escaper": "^2.13.0",
31-
"laminas/laminas-servicemanager": "^3.22.1",
31+
"laminas/laminas-servicemanager": "^4.0",
3232
"mezzio/mezzio-template": "^2.9.0",
3333
"psr/http-message": "^1.0 || ^2.0",
3434
"psr/http-server-middleware": "^1.0.2"
3535
},
3636
"require-dev": {
37-
"laminas/laminas-coding-standard": "^2.5.0",
37+
"laminas/laminas-coding-standard": "^3.0.0",
3838
"phpunit/phpunit": "^10.4.2",
3939
"vimeo/psalm": "^5.16.0"
4040
},
@@ -51,7 +51,8 @@
5151
"scripts": {
5252
"check": [
5353
"@cs-check",
54-
"@test"
54+
"@test",
55+
"@static-analysis"
5556
],
5657
"cs-check": "phpcs",
5758
"cs-fix": "phpcbf",

docs/book/index.md

Lines changed: 0 additions & 1 deletion
This file was deleted.

docs/book/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../README.md

docs/book/v3/overview.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# Overview
22

3-
`dot-navigation` is DotKernel's component that allows you to easily define and parse menus inside templates, using a configuration based approach.
3+
`dot-navigation` is Dotkernel's component that allows you to easily define and parse menus inside templates, using a configuration based approach.

mkdocs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ nav:
1717
- "Required Page Options": v3/required-page-options.md
1818
- Usage: v3/usage.md
1919
site_name: dot-navigation
20-
site_description: "DotKernel's component that allows you to easily define and parse menus inside templates, using a configuration based approach."
20+
site_description: "Dotkernel's component that allows you to easily define and parse menus inside templates, using a configuration based approach."
2121
repo_url: "https://github.com/dotkernel/dot-navigation"
2222
plugins:
2323
- search

psalm-baseline.xml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,4 @@
1010
<code>RecursiveIterator</code>
1111
</MissingTemplateParam>
1212
</file>
13-
<file src="src/Provider/ProviderPluginManager.php">
14-
<MissingTemplateParam>
15-
<code>ProviderPluginManager</code>
16-
</MissingTemplateParam>
17-
</file>
1813
</files>

src/Provider/Factory.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
namespace Dot\Navigation\Provider;
66

77
use Dot\Navigation\Exception\RuntimeException;
8+
use Psr\Container\ContainerExceptionInterface;
89
use Psr\Container\ContainerInterface;
910

1011
class Factory implements FactoryInterface
@@ -18,14 +19,17 @@ public function __construct(ContainerInterface $container, ?ProviderPluginManage
1819
$this->providerPluginManager = $providerPluginManager;
1920
}
2021

22+
/**
23+
* @throws ContainerExceptionInterface
24+
*/
2125
public function create(array $specs): ProviderInterface
2226
{
2327
$type = $specs['type'] ?? '';
2428
if (empty($type)) {
2529
throw new RuntimeException('Undefined navigation provider type');
2630
}
2731

28-
return $this->getProviderPluginManager()->get($type, $specs['options'] ?? null);
32+
return $this->getProviderPluginManager()->build($type, $specs['options'] ?? null);
2933
}
3034

3135
public function getProviderPluginManager(): ProviderPluginManager

src/Provider/ProviderPluginManager.php

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,42 @@
55
namespace Dot\Navigation\Provider;
66

77
use Laminas\ServiceManager\AbstractPluginManager;
8+
use Laminas\ServiceManager\Exception\InvalidServiceException;
89
use Laminas\ServiceManager\Factory\InvokableFactory;
910

11+
use function gettype;
12+
use function is_object;
13+
use function sprintf;
14+
15+
/**
16+
* @template InstanceType
17+
* @extends AbstractPluginManager<InstanceType>
18+
*/
1019
class ProviderPluginManager extends AbstractPluginManager
1120
{
12-
/** @var string $instanceOf */
13-
protected $instanceOf = ProviderInterface::class;
21+
protected string $instanceOf = ProviderInterface::class;
1422

15-
/** @var array */
16-
protected $factories = [
23+
protected array $factories = [
1724
ArrayProvider::class => InvokableFactory::class,
1825
];
1926

20-
/** @var string[] $aliases */
21-
protected $aliases = [
27+
protected array $aliases = [
2228
'arrayprovider' => ArrayProvider::class,
2329
'arrayProvider' => ArrayProvider::class,
2430
'ArrayProvider' => ArrayProvider::class,
2531
'array' => ArrayProvider::class,
2632
'Array' => ArrayProvider::class,
2733
];
34+
35+
public function validate(mixed $instance): void
36+
{
37+
if (! $instance instanceof $this->instanceOf) {
38+
throw new InvalidServiceException(sprintf(
39+
'%s can only create instances of %s; %s is invalid',
40+
static::class,
41+
$this->instanceOf,
42+
is_object($instance) ? $instance::class : gettype($instance)
43+
));
44+
}
45+
}
2846
}

0 commit comments

Comments
 (0)