@@ -29,11 +29,11 @@ class CronCommand extends Command
29
29
const INPUT_KEY_GROUP = 'group ' ;
30
30
31
31
/**
32
- * Object Manager
32
+ * Object manager factory
33
33
*
34
- * @var ObjectManagerInterface
34
+ * @var ObjectManagerFactory
35
35
*/
36
- protected $ objectManager ;
36
+ private $ objectManagerFactory ;
37
37
38
38
/**
39
39
* Constructor
@@ -42,10 +42,7 @@ class CronCommand extends Command
42
42
*/
43
43
public function __construct (ObjectManagerFactory $ objectManagerFactory )
44
44
{
45
- $ params = $ _SERVER ;
46
- $ params [StoreManager::PARAM_RUN_CODE ] = 'admin ' ;
47
- $ params [Store::CUSTOM_ENTRY_POINT_PARAM ] = true ;
48
- $ this ->objectManager = $ objectManagerFactory ->create ($ params );
45
+ $ this ->objectManagerFactory = $ objectManagerFactory ;
49
46
parent ::__construct ();
50
47
}
51
48
@@ -80,6 +77,11 @@ protected function configure()
80
77
*/
81
78
protected function execute (InputInterface $ input , OutputInterface $ output )
82
79
{
80
+ $ omParams = $ _SERVER ;
81
+ $ omParams [StoreManager::PARAM_RUN_CODE ] = 'admin ' ;
82
+ $ omParams [Store::CUSTOM_ENTRY_POINT_PARAM ] = true ;
83
+ $ objectManager = $ this ->objectManagerFactory ->create ($ omParams );
84
+
83
85
$ params [self ::INPUT_KEY_GROUP ] = $ input ->getOption (self ::INPUT_KEY_GROUP );
84
86
$ params [Observer::STANDALONE_PROCESS_STARTED ] = '0 ' ;
85
87
$ bootstrap = $ input ->getOption (Cli::INPUT_KEY_BOOTSTRAP );
@@ -94,7 +96,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
94
96
}
95
97
}
96
98
/** @var \Magento\Framework\App\Cron $cronObserver */
97
- $ cronObserver = $ this -> objectManager ->create ('Magento\Framework\App\Cron ' , ['parameters ' => $ params ]);
99
+ $ cronObserver = $ objectManager ->create ('Magento\Framework\App\Cron ' , ['parameters ' => $ params ]);
98
100
$ cronObserver ->launch ();
99
101
$ output ->writeln ('<info> ' . 'Ran jobs by schedule. ' . '</info> ' );
100
102
}
0 commit comments