1 | <?php |
||
29 | class AbstractUrlRewriteCommand extends Command |
||
30 | { |
||
31 | |||
32 | /** |
||
33 | * @var \Symfony\Component\Console\Helper\ProgressBar |
||
34 | */ |
||
35 | protected $progressBar; |
||
36 | |||
37 | /** |
||
38 | * @var \Magento\Framework\ObjectManagerInterface |
||
39 | */ |
||
40 | protected $objectManager; |
||
41 | /** |
||
42 | * @var \Symfony\Component\Console\Output\OutputInterface |
||
43 | */ |
||
44 | protected $output; |
||
45 | /** |
||
46 | * @var \Magento\Framework\App\ObjectManagerFactory |
||
47 | */ |
||
48 | private $objectManagerFactory; |
||
49 | |||
50 | /** |
||
51 | * @param \Magento\Framework\App\ObjectManagerFactory $objectManagerFactory |
||
52 | * @internal param \Magento\Framework\ObjectManagerInterface $objectManager |
||
53 | * @internal param \Magento\Framework\App\State $state |
||
54 | */ |
||
55 | public function __construct( |
||
63 | |||
64 | /** |
||
65 | * {@inheritdoc} |
||
66 | */ |
||
67 | protected function execute(InputInterface $input, OutputInterface $output) |
||
72 | |||
73 | /** |
||
74 | * Setup progress bar |
||
75 | */ |
||
76 | private function setupProgress() |
||
83 | |||
84 | /** |
||
85 | * Replace data with new product urls |
||
86 | * |
||
87 | * @param $urls |
||
88 | */ |
||
89 | protected function replaceUrls(array $urls) |
||
99 | |||
100 | /** |
||
101 | * Get Url UrlPersist |
||
102 | * @return \Magento\UrlRewrite\Model\UrlPersistInterface |
||
103 | */ |
||
104 | protected function getUrlPersist() |
||
109 | |||
110 | /** |
||
111 | * Gets initialized object manager |
||
112 | * |
||
113 | * @return \Magento\Framework\ObjectManagerInterface |
||
114 | */ |
||
115 | protected function getObjectManager() |
||
128 | } |
Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable: