|
7 | 7 | namespace Magento\Developer\Console\Command;
|
8 | 8 |
|
9 | 9 | use Magento\Developer\Model\Di\Information;
|
10 |
| -use Magento\Framework\App\ObjectManager; |
| 10 | +use Magento\Framework\ObjectManagerInterface; |
11 | 11 | use Symfony\Component\Console\Command\Command;
|
12 | 12 | use Symfony\Component\Console\Exception\InvalidArgumentException;
|
13 | 13 | use Symfony\Component\Console\Helper\Table;
|
|
19 | 19 |
|
20 | 20 | class DiInfoCommand extends Command
|
21 | 21 | {
|
| 22 | + /** |
| 23 | + * @var ObjectManagerInterface |
| 24 | + */ |
| 25 | + private ObjectManagerInterface $objectManager; |
| 26 | + |
| 27 | + |
22 | 28 | /**
|
23 | 29 | * Command name
|
24 | 30 | */
|
@@ -50,10 +56,12 @@ class DiInfoCommand extends Command
|
50 | 56 | */
|
51 | 57 | public function __construct(
|
52 | 58 | Information $diInformation,
|
| 59 | + ObjectManagerInterface $objectManager, |
53 | 60 | ?AreaList $areaList = null
|
54 | 61 | )
|
55 | 62 | {
|
56 | 63 | $this->diInformation = $diInformation;
|
| 64 | + $this->objectManager = $objectManager; |
57 | 65 | $this->areaList = $areaList ?? \Magento\Framework\App\ObjectManager::getInstance()->get(AreaList::class);
|
58 | 66 | parent::__construct();
|
59 | 67 | }
|
@@ -203,18 +211,16 @@ protected function execute(InputInterface $input, OutputInterface $output)
|
203 | 211 | * @return void
|
204 | 212 | * @throws \InvalidArgumentException
|
205 | 213 | */
|
206 |
| - private function setDiArea($area): void |
| 214 | + private function setDiArea(string $area): void |
207 | 215 | {
|
208 | 216 | if ($this->validateAreaCodeFromInput($area)) {
|
209 |
| - $objectManager = ObjectManager::getInstance(); |
210 |
| - |
211 |
| - $areaOmConfiguration = $objectManager |
| 217 | + $areaOmConfiguration = $this->objectManager |
212 | 218 | ->get(\Magento\Framework\App\ObjectManager\ConfigLoader::class)
|
213 | 219 | ->load($area);
|
214 | 220 |
|
215 |
| - $objectManager->configure($areaOmConfiguration); |
| 221 | + $this->objectManager->configure($areaOmConfiguration); |
216 | 222 |
|
217 |
| - $objectManager->get(\Magento\Framework\Config\ScopeInterface::class) |
| 223 | + $this->objectManager->get(\Magento\Framework\Config\ScopeInterface::class) |
218 | 224 | ->setCurrentScope($area);
|
219 | 225 | } else {
|
220 | 226 | throw new InvalidArgumentException(sprintf('The "%s" area code does not exist', $area));
|
|
0 commit comments