Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
UninstallCollector.php
Go to the documentation of this file.
1 <?php
6 namespace Magento\Setup\Model;
7 
12 
17 {
23  private $objectManager;
24 
30  private $dataSetupFactory;
31 
38  public function __construct(
39  ObjectManagerProvider $objectManagerProvider,
40  DataSetupFactory $dataSetupFactory
41  ) {
42  $this->objectManager = $objectManagerProvider->get();
43  $this->dataSetupFactory = $dataSetupFactory;
44  }
45 
52  public function collectUninstall($filterModules = [])
53  {
54  $uninstallList = [];
56  $setup = $this->dataSetupFactory->create();
57  $result = $setup->getConnection()->select()->from($setup->getTable('setup_module'), ['module']);
58  if (isset($filterModules) && sizeof($filterModules) > 0) {
59  $result->where('module in( ? )', $filterModules);
60  }
61  // go through modules
62  foreach ($setup->getConnection()->fetchAll($result) as $row) {
63  $uninstallClassName = str_replace('_', '\\', $row['module']) . '\Setup\Uninstall';
64  if (class_exists($uninstallClassName)) {
65  $uninstallClass = $this->objectManager->create($uninstallClassName);
66  if (is_subclass_of($uninstallClass, \Magento\Framework\Setup\UninstallInterface::class)) {
67  $uninstallList[$row['module']] = $uninstallClass;
68  }
69  }
70  }
71 
72  return $uninstallList;
73  }
74 }
is_subclass_of($obj, $className)
$setup
Definition: trigger.php:12
__construct(ObjectManagerProvider $objectManagerProvider, DataSetupFactory $dataSetupFactory)