Skip to content

Commit f006a5a

Browse files
Dnyaneshwar S JambhulkarDnyaneshwar S Jambhulkar
authored andcommitted
AC-15068::Laminas MVC Retiring
1 parent e82cd70 commit f006a5a

File tree

9 files changed

+75
-56
lines changed

9 files changed

+75
-56
lines changed

lib/internal/Magento/Framework/Setup/Mvc/ModuleManagerFactory.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ class ModuleManagerFactory
1919
* @param string $name
2020
* @param array|null $options
2121
* @return ModuleManager
22+
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
2223
*/
2324
public function __invoke(mixed $container, string $name, ?array $options = null): ModuleManager
2425
{

lib/internal/Magento/Framework/Setup/Mvc/MvcApplication.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ private static function loadAutoloadConfig(ServiceManager $serviceManager, array
180180
}
181181

182182
// Load Setup module configuration
183-
if (class_exists('Magento\Setup\Module')) {
183+
if (class_exists(\Magento\Setup\Module::class)) {
184184
$module = new \Magento\Setup\Module();
185185
$moduleConfig = $module->getConfig();
186186
$mergedConfig = array_merge_recursive($mergedConfig, $moduleConfig);

lib/internal/Magento/Framework/Setup/Mvc/MvcServiceManagerConfig.php

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,9 @@ public function __construct(array $config = [])
4747
],
4848
'delegators' => [],
4949
'factories' => [
50-
'EventManager' => function($container) {
51-
$sharedManager = $container->has('SharedEventManager') ? $container->get('SharedEventManager') : null;
50+
'EventManager' => function ($container) {
51+
$sharedManager = $container->has('SharedEventManager') ?
52+
$container->get('SharedEventManager') : null;
5253
return new \Laminas\EventManager\EventManager($sharedManager);
5354
},
5455
'ModuleManager' => ModuleManagerFactory::class,
@@ -64,17 +65,17 @@ public function __construct(array $config = [])
6465
];
6566

6667
// Add ServiceManager factory (same as original)
67-
$this->config['factories']['ServiceManager'] = function($container) {
68+
$this->config['factories']['ServiceManager'] = function ($container) {
6869
return $container;
6970
};
7071

7172
// Add SharedEventManager factory (same as original)
72-
$this->config['factories']['SharedEventManager'] = function() {
73+
$this->config['factories']['SharedEventManager'] = function () {
7374
return new \Laminas\EventManager\SharedEventManager();
7475
};
7576

7677
// Add EventManagerAware initializer (same as original)
77-
$this->config['initializers']['EventManagerAwareInitializer'] = function($container, $instance) {
78+
$this->config['initializers']['EventManagerAwareInitializer'] = function ($container, $instance) {
7879
if (!$instance instanceof \Laminas\EventManager\EventManagerAwareInterface) {
7980
return;
8081
}
@@ -92,9 +93,6 @@ public function __construct(array $config = [])
9293
if (!empty($config)) {
9394
$this->config = array_merge_recursive($this->config, $config);
9495
}
95-
96-
// Add InitParamListener as an invokable service (same as Laminas does)
97-
$this->config['invokables'][\Magento\Setup\Mvc\Bootstrap\InitParamListener::class] = \Magento\Setup\Mvc\Bootstrap\InitParamListener::class;
9896
}
9997

10098
/**

lib/internal/Magento/Framework/Setup/Mvc/ServiceListenerFactory.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
declare(strict_types=1);
77

88
namespace Magento\Framework\Setup\Mvc;
9+
910
use Laminas\ModuleManager\Listener\ServiceListener;
1011
use Laminas\ServiceManager\ServiceManager;
1112

@@ -21,6 +22,7 @@ class ServiceListenerFactory
2122
* @param string $name
2223
* @param array|null $options
2324
* @return ServiceListener
25+
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
2426
*/
2527
public function __invoke(ServiceManager $container, string $name, ?array $options = null): ServiceListener
2628
{

setup/src/Magento/Setup/Application.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/**
3-
* Copyright © Magento, Inc. All rights reserved.
4-
* See COPYING.txt for license details.
3+
* Copyright 2017 Adobe
4+
* All Rights Reserved.
55
*/
66
namespace Magento\Setup;
77

setup/src/Magento/Setup/Module.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/**
3-
* Copyright © Magento, Inc. All rights reserved.
4-
* See COPYING.txt for license details.
3+
* Copyright 2014 Adobe
4+
* All Rights Reserved.
55
*/
66

77
namespace Magento\Setup;
@@ -15,13 +15,18 @@ class Module
1515
{
1616
/**
1717
* Native bootstrap method
18+
*
19+
* @param MvcEvent $e
20+
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
1821
*/
22+
// phpcs:disable
1923
public function onBootstrap(MvcEvent $e)
2024
{
2125
// Simplified native bootstrap for CLI setup commands
2226
// Most of the original functionality (headers, routing) is not needed for setup commands
2327
// The main purpose is to initialize basic services for compatibility
2428
}
29+
// phpcs:disable
2530

2631
/**
2732
* @inheritDoc

setup/src/Magento/Setup/Mvc/Bootstrap/InitParamListener.php

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818

1919
/**
2020
* A listener that injects relevant Magento initialization parameters and initializes filesystem
21-
*
21+
* @deprecated Not used anymore
22+
* @see we don't use it anymore
2223
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
2324
* @codingStandardsIgnoreStart
2425
*/
@@ -29,44 +30,6 @@ class InitParamListener
2930
*/
3031
const BOOTSTRAP_PARAM = 'magento-init-params';
3132

32-
33-
34-
/**
35-
* An event subscriber that initializes DirectoryList and Filesystem objects in ZF application bootstrap
36-
*
37-
* @param MvcEvent $e
38-
* @return void
39-
*/
40-
public function onBootstrap(MvcEvent $e): void
41-
{
42-
/** @var MvcApplication $application */
43-
$application = $e->getApplication();
44-
$initParams = $application->getServiceManager()->get(self::BOOTSTRAP_PARAM);
45-
$directoryList = $this->createDirectoryList($initParams);
46-
$serviceManager = $application->getServiceManager();
47-
$serviceManager->setService(\Magento\Framework\App\Filesystem\DirectoryList::class, $directoryList);
48-
$serviceManager->setService(\Magento\Framework\Filesystem::class, $this->createFilesystem($directoryList));
49-
}
50-
51-
/**
52-
* Factory method for creating init parameters (compatible with Laminas ServiceManager)
53-
*
54-
* @param mixed $serviceManager Laminas ServiceManager
55-
* @param string $requestedName
56-
* @return array
57-
*/
58-
public function __invoke($serviceManager, $requestedName): array
59-
{
60-
// For Laminas ServiceManager, extract parameters from merged config (which includes global.php)
61-
$mergedConfig = $serviceManager->has('config') ? $serviceManager->get('config') : [];
62-
$appConfig = $serviceManager->has('ApplicationConfig') ? $serviceManager->get('ApplicationConfig') : [];
63-
64-
// Merge both configs to ensure we get bootstrap params from global.php
65-
$fullConfig = array_merge_recursive($appConfig, $mergedConfig);
66-
67-
return $this->extractInitParametersFromConfig($fullConfig);
68-
}
69-
7033
/**
7134
* Attach listener to events (compatibility method for tests)
7235
*
@@ -98,6 +61,23 @@ public function detach(EventManagerInterface $events): void
9861
$events->detach([$this, 'onBootstrap']);
9962
}
10063

64+
/**
65+
* An event subscriber that initializes DirectoryList and Filesystem objects in ZF application bootstrap
66+
*
67+
* @param MvcEvent $e
68+
* @return void
69+
*/
70+
public function onBootstrap(MvcEvent $e): void
71+
{
72+
/** @var MvcApplication $application */
73+
$application = $e->getApplication();
74+
$initParams = $application->getServiceManager()->get(self::BOOTSTRAP_PARAM);
75+
$directoryList = $this->createDirectoryList($initParams);
76+
$serviceManager = $application->getServiceManager();
77+
$serviceManager->setService(\Magento\Framework\App\Filesystem\DirectoryList::class, $directoryList);
78+
$serviceManager->setService(\Magento\Framework\Filesystem::class, $this->createFilesystem($directoryList));
79+
}
80+
10181
/**
10282
* Create service (compatibility method for tests)
10383
*
@@ -111,6 +91,26 @@ public function createService($serviceLocator): array
11191
return $this->extractInitParametersFromConfig($config);
11292
}
11393

94+
/**
95+
* Factory method for creating init parameters (compatible with Laminas ServiceManager)
96+
*
97+
* @param mixed $serviceManager Laminas ServiceManager
98+
* @param string $requestedName
99+
* @return array
100+
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
101+
*/
102+
public function __invoke($serviceManager, $requestedName): array
103+
{
104+
// For Laminas ServiceManager, extract parameters from merged config (which includes global.php)
105+
$mergedConfig = $serviceManager->has('config') ? $serviceManager->get('config') : [];
106+
$appConfig = $serviceManager->has('ApplicationConfig') ? $serviceManager->get('ApplicationConfig') : [];
107+
108+
// Merge both configs to ensure we get bootstrap params from global.php
109+
$fullConfig = array_merge_recursive($appConfig, $mergedConfig);
110+
111+
return $this->extractInitParametersFromConfig($fullConfig);
112+
}
113+
114114
/**
115115
* Collects init params configuration from multiple sources
116116
*

setup/src/Magento/Setup/Mvc/View/Http/InjectTemplateListener.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111

1212
/**
1313
* Native InjectTemplateListener for HTTP request (replaces Laminas dependency)
14+
*
15+
* @deprecated Not used anymore
16+
* @see we don't use it anymore
1417
*/
1518
class InjectTemplateListener
1619
{
@@ -61,11 +64,14 @@ protected function deriveControllerSubNamespace($namespace): string
6164
*
6265
* @param MvcEvent $e
6366
* @return void
67+
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
6468
*/
69+
// phpcs:disable
6570
public function injectTemplate(MvcEvent $e)
6671
{
6772
// Native implementation - simplified for setup context
6873
// In setup context, we don't need complex template injection
6974
// This method exists for API compatibility
7075
}
76+
// phpcs:disable
7177
}

setup/src/Magento/Setup/Test/Unit/Mvc/Bootstrap/InitParamListenerTest.php

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@ class InitParamListenerTest extends TestCase
3333
*/
3434
private $listener;
3535

36-
/** callable[][] */
36+
/**
37+
* @var array
38+
*/
3739
private $callbacks = [];
3840

3941
protected function setUp(): void
@@ -172,13 +174,16 @@ public static function createServiceDataProvider()
172174
'one MAGE_DIRS CLI' => [
173175
[],
174176
[],
175-
['bin/magento', 'setup:install', '--magento-init-params=MAGE_MODE=developer&MAGE_DIRS[base][path]=/var/www/magento2'],
177+
['bin/magento', 'setup:install',
178+
'--magento-init-params=MAGE_MODE=developer&MAGE_DIRS[base][path]=/var/www/magento2'],
176179
['MAGE_DIRS' => ['base' => ['path' => '/var/www/magento2']], 'MAGE_MODE' => 'developer'],
177180
],
178181
'two MAGE_DIRS CLI' => [
179182
[],
180183
[],
181-
['bin/magento', 'setup:install', '--magento-init-params=MAGE_MODE=developer&MAGE_DIRS[base][path]=/var/www/magento2&MAGE_DIRS[cache][path]=/tmp/cache'],
184+
['bin/magento', 'setup:install',
185+
'--magento-init-params=MAGE_MODE=developer&MAGE_DIRS[base][path]
186+
=/var/www/magento2&MAGE_DIRS[cache][path]=/tmp/cache'],
182187
[
183188
'MAGE_DIRS' => ['base' => ['path' => '/var/www/magento2'], 'cache' => ['path' => '/tmp/cache']],
184189
'MAGE_MODE' => 'developer',
@@ -199,7 +204,9 @@ public static function createServiceDataProvider()
199204
'two MAGE_DIRS' => [
200205
[],
201206
[],
202-
['bin/magento', 'setup:install', '--magento-init-params=MAGE_MODE=developer&MAGE_DIRS[base][path]=/var/www/magento2&MAGE_DIRS[cache][path]=/tmp/cache'],
207+
['bin/magento', 'setup:install',
208+
'--magento-init-params=MAGE_MODE=developer&MAGE_DIRS[base][path]
209+
=/var/www/magento2&MAGE_DIRS[cache][path]=/tmp/cache'],
203210
[
204211
'MAGE_DIRS' => ['base' => ['path' => '/var/www/magento2'], 'cache' => ['path' => '/tmp/cache']],
205212
'MAGE_MODE' => 'developer',

0 commit comments

Comments
 (0)