Skip to content

Commit

Permalink
Merge branch '31173-laminas-di-dependency' of github.com:ProkopovVita…
Browse files Browse the repository at this point in the history
…liy/magento2 into php8-develop
  • Loading branch information
sivaschenko committed Mar 9, 2021
2 parents a76bcb6 + c9f729b commit 21c3055
Show file tree
Hide file tree
Showing 12 changed files with 460 additions and 234 deletions.
17 changes: 9 additions & 8 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
"colinmollenhour/credis": "1.11.1",
"colinmollenhour/php-redis-session-abstract": "~1.4.0",
"composer/composer": "^1.9 || ^2.0",
"magento/magento-composer-installer": ">=0.1.11",
"elasticsearch/elasticsearch": "~7.11.0",
"guzzlehttp/guzzle": "^6.3.3",
"laminas/laminas-captcha": "^2.7.1",
Expand All @@ -42,7 +41,7 @@
"laminas/laminas-crypt": "^3.4.0",
"laminas/laminas-db": "^2.8.2",
"laminas/laminas-dependency-plugin": "^2.1.0",
"laminas/laminas-di": "^2.6.1",
"laminas/laminas-di": "^3.2.0",
"laminas/laminas-eventmanager": "^3.0.0",
"laminas/laminas-feed": "^2.9.0",
"laminas/laminas-form": "^2.10.0",
Expand All @@ -53,18 +52,23 @@
"laminas/laminas-mail": "^2.9.0",
"laminas/laminas-mime": "^2.5.0",
"laminas/laminas-modulemanager": "^2.7",
"laminas/laminas-mvc": "~2.7.0",
"laminas/laminas-mvc": "^3.2.0",
"laminas/laminas-mvc-console": "^1.3.0",
"laminas/laminas-serializer": "^2.7.2",
"laminas/laminas-server": "^2.6.1",
"laminas/laminas-servicemanager": "^2.7.8",
"laminas/laminas-servicemanager": "^3.6.0",
"laminas/laminas-session": "^2.7.3",
"laminas/laminas-soap": "^2.7.0",
"laminas/laminas-stdlib": "^3.2.1",
"laminas/laminas-text": "^2.6.0",
"laminas/laminas-uri": "^2.5.1",
"laminas/laminas-validator": "^2.6.0",
"laminas/laminas-view": "~2.11.2",
"league/flysystem": "^1.0",
"league/flysystem-aws-s3-v3": "^1.0",
"league/flysystem-cached-adapter": "^1.0",
"magento/composer": "1.6.0",
"magento/magento-composer-installer": ">=0.1.11",
"magento/zendframework1": "~1.14.2",
"monolog/monolog": "^1.17",
"paragonie/sodium_compat": "^1.6",
Expand All @@ -79,10 +83,7 @@
"tedivm/jshrink": "~1.4.0",
"tubalmartin/cssmin": "4.1.1",
"webonyx/graphql-php": "^0.13.8",
"wikimedia/less.php": "^3.0.0",
"league/flysystem": "^1.0",
"league/flysystem-aws-s3-v3": "^1.0",
"league/flysystem-cached-adapter": "^1.0"
"wikimedia/less.php": "^3.0.0"
},
"require-dev": {
"allure-framework/allure-phpunit": "~1.2.0",
Expand Down
543 changes: 354 additions & 189 deletions composer.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion lib/internal/Magento/Framework/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"laminas/laminas-http": "^2.6.0",
"laminas/laminas-mail": "^2.9.0",
"laminas/laminas-mime": "^2.5.0",
"laminas/laminas-mvc": "~2.7.0",
"laminas/laminas-mvc": "^3.2.0",
"laminas/laminas-stdlib": "^3.2.1",
"laminas/laminas-uri": "^2.5.1",
"laminas/laminas-validator": "^2.6.0",
Expand Down
18 changes: 8 additions & 10 deletions setup/config/application.config.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,11 @@
* See COPYING.txt for license details.
*/

use Magento\Setup\Di\MagentoDiFactory;
use Magento\Setup\Mvc\Bootstrap\InitParamListener;
use Laminas\Mvc\Service\DiAbstractServiceFactoryFactory;
use Laminas\ServiceManager\Di\DiAbstractServiceFactory;

return [
'modules' => [
'Magento\Setup',
],
'modules' => require __DIR__ . '/modules.config.php',
'module_listener_options' => [
'module_paths' => [
__DIR__ . '/../src',
Expand All @@ -25,12 +22,13 @@
],
'service_manager' => [
'factories' => [
DiAbstractServiceFactory::class => DiAbstractServiceFactoryFactory::class,
InitParamListener::BOOTSTRAP_PARAM => InitParamListener::class,
\Magento\Framework\App\MaintenanceMode::class => MagentoDiFactory::class,
\Magento\Setup\Model\ConfigGenerator::class => MagentoDiFactory::class,
\Magento\Indexer\Console\Command\IndexerReindexCommand::class => MagentoDiFactory::class,
\Symfony\Component\Console\Helper\TableFactory::class => MagentoDiFactory::class,
\Magento\Deploy\Console\InputValidator::class => MagentoDiFactory::class,
\Magento\Framework\App\State::class => MagentoDiFactory::class,
],
],
// list of Magento specific required services, like default abstract factory
'required_services' => [
DiAbstractServiceFactory::class
]
];
22 changes: 12 additions & 10 deletions setup/config/di.config.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,26 @@
use Magento\Framework\Setup\Declaration\Schema\SchemaConfig;

return [
'di' => [
'instance' => [
'preference' => [
'dependencies' => [
'auto' => [
'preferences' => [
EventManagerInterface::class => 'EventManager',
ServiceLocatorInterface::class => ServiceManager::class,
LoggerInterface::class => Quiet::class,
ConfigInterface::class => Config::class,
DriverInterface::class => \Magento\Framework\Filesystem\Driver\File::class,
ComponentRegistrarInterface::class => ComponentRegistrar::class,
],
SchemaConfig::class => [
'parameters' => [
'connectionScopes' => [
'default',
'checkout',
'sales'
'types' => [
SchemaConfig::class => [
'parameters' => [
'connectionScopes' => [
'default',
'checkout',
'sales'
]
]
]
],
],
],
],
Expand Down
27 changes: 27 additions & 0 deletions setup/config/modules.config.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
/**
* List of enabled modules for this application.
*
* This should be an array of module namespaces used in the application.
*/
return [
'Magento\Setup',
'Laminas\Db',
'Laminas\Di',
'Laminas\Form',
'Laminas\Filter',
'Laminas\Hydrator',
'Laminas\I18n',
'Laminas\InputFilter',
'Laminas\Log',
'Laminas\Mail',
'Laminas\Router',
'Laminas\Serializer',
'Laminas\Session',
'Laminas\Validator',
'Laminas\Mvc\Console'
];
1 change: 0 additions & 1 deletion setup/src/Magento/Setup/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ public function bootstrap(array $configuration)

$listeners = $this->getListeners($serviceManager, $configuration);
$application = new LaminasApplication(
$configuration,
$serviceManager,
$serviceManager->get('EventManager'),
$serviceManager->get('Request'),
Expand Down
2 changes: 1 addition & 1 deletion setup/src/Magento/Setup/Console/Command/BackupCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ function () use ($input, $output) {
$output,
false
);

return $returnValue;
}

Expand Down
26 changes: 26 additions & 0 deletions setup/src/Magento/Setup/Di/MagentoDiFactory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);

namespace Magento\Setup\Di;

use Interop\Container\ContainerInterface;
use Laminas\ServiceManager\Factory\FactoryInterface;
use Magento\Framework\App\ObjectManager;

/**
* Instantiates the type via Magento object manager
*/
class MagentoDiFactory implements FactoryInterface
{
/**
* @inheritdoc
*/
public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
{
return ObjectManager::getInstance()->get($requestedName);
}
}
26 changes: 17 additions & 9 deletions setup/src/Magento/Setup/Mvc/Bootstrap/InitParamListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@
*/
namespace Magento\Setup\Mvc\Bootstrap;

use Interop\Container\ContainerInterface;
use Magento\Framework\App\Bootstrap as AppBootstrap;
use Magento\Framework\App\Filesystem\DirectoryList;
use Magento\Framework\App\ObjectManager;
use Magento\Framework\App\Request\Http;
use Magento\Framework\App\State;
use Magento\Framework\Filesystem;
use Magento\Framework\Shell\ComplexParameter;
Expand All @@ -17,11 +16,9 @@
use Laminas\EventManager\ListenerAggregateInterface;
use Laminas\Mvc\Application;
use Laminas\Mvc\MvcEvent;
use Laminas\Router\Http\RouteMatch;
use Laminas\ServiceManager\FactoryInterface;
use Laminas\ServiceManager\Factory\FactoryInterface;
use Laminas\ServiceManager\ServiceLocatorInterface;
use Laminas\Stdlib\RequestInterface;
use Laminas\Uri\UriInterface;

/**
* A listener that injects relevant Magento initialization parameters and initializes filesystem
Expand All @@ -37,7 +34,7 @@ class InitParamListener implements ListenerAggregateInterface, FactoryInterface
const BOOTSTRAP_PARAM = 'magento-init-params';

/**
* @var \Laminas\Stdlib\CallbackHandler[]
* @var callable[]
*/
private $listeners = [];

Expand Down Expand Up @@ -97,14 +94,25 @@ public function onBootstrap(MvcEvent $e)
}

/**
* @inheritdoc
* Create service. Proxy to the __invoke method
*
* @deprecared use the __invoke method instead
*
* @param ServiceLocatorInterface $serviceLocator
* @return mixed
* @return array
* @throws \Interop\Container\Exception\ContainerException
*/
public function createService(ServiceLocatorInterface $serviceLocator)
{
return $this->extractInitParameters($serviceLocator->get('Application'));
return $this($serviceLocator, 'Application');
}

/**
* @inheritdoc
*/
public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
{
return $this->extractInitParameters($container->get('Application'));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,17 +121,17 @@ public function testCreateDirectoryListException()
public function testCreateServiceNotConsole()
{
/**
* @var ServiceLocatorInterface|MockObject $serviceLocator
* @var ServiceLocatorInterface|MockObject $container
*/
$serviceLocator = $this->getMockForAbstractClass(ServiceLocatorInterface::class);
$container = $this->getMockForAbstractClass(ServiceLocatorInterface::class);
$mvcApplication = $this->getMockBuilder(Application::class)
->disableOriginalConstructor()
->getMock();
$request = $this->getMockForAbstractClass(RequestInterface::class);
$mvcApplication->expects($this->any())->method('getRequest')->willReturn($request);
$serviceLocator->expects($this->once())->method('get')->with('Application')
$container->expects($this->once())->method('get')->with('Application')
->willReturn($mvcApplication);
$this->assertEquals([], $this->listener->createService($serviceLocator));
$this->assertEquals([], $this->listener->createService($container));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
use Laminas\Log\ProcessorPluginManager as LogProcessorManager;
use Laminas\Log\WriterPluginManager as LogWriterManager;
use Laminas\Serializer\AdapterPluginManager as SerializerAdapterManager;
use Laminas\ServiceManager\AbstractFactoryInterface;
use Laminas\ServiceManager\Factory\AbstractFactoryInterface;
use Laminas\ServiceManager\Exception\ServiceNotFoundException;
use Laminas\ServiceManager\ServiceLocatorInterface;
use Laminas\Stdlib\DispatchableInterface;
Expand Down

0 comments on commit 21c3055

Please sign in to comment.