Skip to content

Commit 8c88f6e

Browse files
authored
Merge pull request #59 from AntePrkacin/NGSTACK-1006-upgrade-bundle-to-Ibexa-5
Upgrade bundle to ibexa 5
2 parents 28b38cb + adf51a6 commit 8c88f6e

File tree

13 files changed

+86
-132
lines changed

13 files changed

+86
-132
lines changed

.github/workflows/tests.yml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,9 @@ jobs:
1414
strategy:
1515
fail-fast: false
1616
matrix:
17-
php: ['7.4', '8.0', '8.1']
18-
symfony: ['~5.4.0']
17+
php: ['8.3']
18+
symfony: ['~7.3.0']
1919
deps: ['normal']
20-
include:
21-
- php: '7.4'
22-
symfony: '~5.4.0'
23-
deps: 'low'
2420

2521
steps:
2622
- uses: actions/checkout@v2
@@ -34,6 +30,7 @@ jobs:
3430

3531
# Install Flex as a global dependency to enable usage of extra.symfony.require
3632
# while keeping Flex recipes from applying
33+
- run: composer global config --no-plugins allow-plugins.symfony/flex true
3734
- run: composer global require --no-scripts symfony/flex
3835

3936
- run: composer config extra.symfony.require ${{ matrix.symfony }}

DependencyInjection/Compiler/ParameterProviderPass.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
namespace Lolautruche\EzCoreExtraBundle\DependencyInjection\Compiler;
1313

14-
use LogicException;
1514
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
1615
use Symfony\Component\DependencyInjection\ContainerBuilder;
1716
use Symfony\Component\DependencyInjection\Reference;
@@ -21,7 +20,7 @@
2120
*/
2221
class ParameterProviderPass implements CompilerPassInterface
2322
{
24-
public function process(ContainerBuilder $container)
23+
public function process(ContainerBuilder $container): void
2524
{
2625
if (!$container->hasDefinition('ez_core_extra.view_template_listener')) {
2726
return;
@@ -34,7 +33,7 @@ public function process(ContainerBuilder $container)
3433
'addParameterProvider',
3534
[
3635
new Reference($id),
37-
isset($attribute['alias']) ? $attribute['alias'] : $id,
36+
$attribute['alias'] ?? $id,
3837
]
3938
);
4039
}

DependencyInjection/Configuration.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
class Configuration extends SiteAccessConfiguration
1818
{
19-
public function getConfigTreeBuilder()
19+
public function getConfigTreeBuilder(): TreeBuilder
2020
{
2121
$treeBuilder = new TreeBuilder('ez_core_extra');
2222

DependencyInjection/EzCoreExtraExtension.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
class EzCoreExtraExtension extends Extension
2222
{
23-
public function load(array $configs, ContainerBuilder $container)
23+
public function load(array $configs, ContainerBuilder $container): void
2424
{
2525
$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
2626
$loader->load('services.yml');
@@ -38,7 +38,7 @@ public function load(array $configs, ContainerBuilder $container)
3838
}
3939
}
4040

41-
private function configureDesigns(array $config, ConfigurationProcessor $processor, ContainerBuilder $container)
41+
private function configureDesigns(array $config, ConfigurationProcessor $processor, ContainerBuilder $container): void
4242
{
4343
$processor->mapConfigArray('twig_globals', $config);
4444
}

EventListener/ViewTemplateListener.php

Lines changed: 10 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -16,71 +16,43 @@
1616
use Ibexa\Contracts\Core\SiteAccess\ConfigResolverInterface;
1717
use Ibexa\Core\MVC\Symfony\Event\PreContentViewEvent;
1818
use Ibexa\Core\MVC\Symfony\MVCEvents;
19-
use Ibexa\Core\MVC\Symfony\View\ContentValueView;
2019
use Ibexa\Core\MVC\Symfony\View\ContentView;
21-
use Ibexa\Core\MVC\Symfony\View\LocationValueView;
2220
use Lolautruche\EzCoreExtraBundle\Exception\MissingParameterProviderException;
2321
use Lolautruche\EzCoreExtraBundle\View\ConfigurableView;
2422
use Lolautruche\EzCoreExtraBundle\View\ExpressionLanguage;
2523
use Lolautruche\EzCoreExtraBundle\View\ViewParameterProviderInterface;
2624
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
27-
use Symfony\Component\ExpressionLanguage\Expression;
2825

2926
/**
3027
* Listener that will inject pre-configured parameters into matched view.
3128
*/
3229
class ViewTemplateListener implements EventSubscriberInterface
3330
{
34-
/**
35-
* @var ConfigResolverInterface
36-
*/
37-
private $configResolver;
38-
39-
/**
40-
* @var DynamicSettingParserInterface
41-
*/
42-
private $settingParser;
43-
4431
/**
4532
* @var \Lolautruche\EzCoreExtraBundle\View\ViewParameterProviderInterface[]
4633
*/
47-
private $parameterProviders = [];
48-
49-
/**
50-
* @var Repository
51-
*/
52-
private $repository;
53-
54-
/**
55-
* @var ExpressionLanguage
56-
*/
57-
private $expressionLanguage;
34+
private array $parameterProviders = [];
5835

5936
public function __construct(
60-
ConfigResolverInterface $configResolver,
61-
DynamicSettingParserInterface $settingParser,
62-
Repository $repository,
63-
ExpressionLanguage $expressionLanguage
64-
){
65-
$this->configResolver = $configResolver;
66-
$this->settingParser = $settingParser;
67-
$this->repository = $repository;
68-
$this->expressionLanguage = $expressionLanguage;
69-
}
37+
private ConfigResolverInterface $configResolver,
38+
private DynamicSettingParserInterface $settingParser,
39+
private Repository $repository,
40+
private ExpressionLanguage $expressionLanguage,
41+
){}
7042

71-
public static function getSubscribedEvents()
43+
public static function getSubscribedEvents(): array
7244
{
7345
return [
7446
MVCEvents::PRE_CONTENT_VIEW => ['onPreContentView', 15],
7547
];
7648
}
7749

78-
public function addParameterProvider(ViewParameterProviderInterface $provider, $alias)
50+
public function addParameterProvider(ViewParameterProviderInterface $provider, $alias): void
7951
{
8052
$this->parameterProviders[$alias] = $provider;
8153
}
8254

83-
public function onPreContentView(PreContentViewEvent $event)
55+
public function onPreContentView(PreContentViewEvent $event): void
8456
{
8557
/** @var \Ibexa\Core\MVC\Symfony\View\ContentView $view */
8658
$view = $event->getContentView();
@@ -137,7 +109,7 @@ public function onPreContentView(PreContentViewEvent $event)
137109
* @param \Ibexa\Core\MVC\Symfony\View\ContentView $view
138110
* @return ConfigurableView
139111
*/
140-
private function generateConfigurableView(ContentView $view)
112+
private function generateConfigurableView(ContentView $view): ConfigurableView
141113
{
142114
$configurableView = new ConfigurableView($view);
143115
$configurableView->addParameters([

EzCoreExtraBundle.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
class EzCoreExtraBundle extends Bundle
1919
{
20-
public function build(ContainerBuilder $container)
20+
public function build(ContainerBuilder $container): void
2121
{
2222
parent::build($container);
2323
$container->addCompilerPass(new ParameterProviderPass());

Security/Voter/SimplifiedCoreVoter.php

Lines changed: 14 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -19,51 +19,40 @@
1919

2020
class SimplifiedCoreVoter implements VoterInterface
2121
{
22-
const IBEXA_ROLE_PREFIX = 'ibexa:';
22+
const string IBEXA_ROLE_PREFIX = 'ibexa:';
2323

24-
/**
25-
* @var VoterInterface
26-
*/
27-
private $coreVoter;
24+
public function __construct(
25+
private VoterInterface $coreVoter,
26+
private VoterInterface $valueObjectVoter,
27+
) {}
2828

29-
/**
30-
* @var VoterInterface
31-
*/
32-
private $valueObjectVoter;
33-
34-
public function __construct(VoterInterface $coreVoter, VoterInterface $valueObjectVoter)
35-
{
36-
$this->coreVoter = $coreVoter;
37-
$this->valueObjectVoter = $valueObjectVoter;
38-
}
39-
40-
public function supportsAttribute($attribute)
29+
public function supportsAttribute($attribute): bool
4130
{
4231
return is_string($attribute) && stripos($attribute, static::IBEXA_ROLE_PREFIX) === 0;
4332
}
4433

45-
public function supportsClass($class)
34+
public function supportsClass($class): bool
4635
{
4736
return true;
4837
}
4938

50-
public function vote(TokenInterface $token, $object, array $attributes)
39+
public function vote(TokenInterface $token, mixed $subject, array $attributes): int
5140
{
5241
foreach ($attributes as $attribute) {
5342
if (!$this->supportsAttribute($attribute)) {
5443
continue;
5544
}
5645

5746
$attribute = substr($attribute, strlen(static::IBEXA_ROLE_PREFIX));
58-
list($module, $function) = explode(':', $attribute);
47+
[$module, $function] = explode(':', $attribute);
5948
$attributeObject = new AuthorizationAttribute($module, $function);
6049
try {
61-
if ($object instanceof ValueObject) {
62-
$attributeObject->limitations = ['valueObject' => $object];
63-
return $this->valueObjectVoter->vote($token, $object, [$attributeObject]);
64-
} else {
65-
return $this->coreVoter->vote($token, $object, [$attributeObject]);
50+
if ($subject instanceof ValueObject) {
51+
$attributeObject->limitations = ['valueObject' => $subject];
52+
return $this->valueObjectVoter->vote($token, $subject, [$attributeObject]);
6653
}
54+
55+
return $this->coreVoter->vote($token, $subject, [$attributeObject]);
6756
} catch (InvalidArgumentException $e) {
6857
continue;
6958
}

Templating/Twig/TwigGlobalsExtension.php

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,9 @@
2020
*/
2121
class TwigGlobalsExtension extends AbstractExtension implements GlobalsInterface
2222
{
23-
/**
24-
* @var \Ibexa\Contracts\Core\SiteAccess\ConfigResolverInterface
25-
*/
26-
private $configResolver;
27-
28-
public function __construct(ConfigResolverInterface $configResolver)
29-
{
30-
$this->configResolver = $configResolver;
31-
}
23+
public function __construct(
24+
private ConfigResolverInterface $configResolver,
25+
) {}
3226

3327
public function getGlobals(): array
3428
{

0 commit comments

Comments
 (0)