İçin kodların aranıyor UninstallInterfaceverir \Magento\Setup\Model\UninstallCollector.
Eğer ararsanız UninstallCollectoro zaman, kullanılan budur bulacaksınız \Magento\Setup\Console\Command\ModuleUninstallCommand. Özellikle ilgili:
$uninstalls = $this->collector->collectUninstall();
$setupModel = $this->objectManager->get('Magento\Setup\Module\Setup');
foreach ($modules as $module) {
if (isset($uninstalls[$module])) {
$output->writeln("<info>Removing data of $module</info>");
$uninstalls[$module]->uninstall(
$setupModel,
new ModuleContext($this->moduleResource->getDbVersion($module) ?: '')
);
} else {
$output->writeln("<info>No data to clear in $module</info>");
}
}
Bir araya getir, tahmin edebiliriz:
- Modülünüzde bir
Uninstallsınıf içermelidir {module}\Setup\Uninstall.php.
- Bu sınıf uygulanmalıdır
Magento\Framework\Setup\UninstallInterface.
- Bu sınıf,
uninstallgerekli mantığı içeren bir yönteme sahip olmalıdır .
- Herhangi bir kurulum veya yükseltme komut dosyasında olduğu gibi aynı nesneleri ve yöntemleri kullanabilirsiniz.
İşte iskeletiniz:
<?php
namespace \Custom\Module\Setup;
class Uninstall implements \Magento\Framework\Setup\UninstallInterface
{
/**
* Module uninstall code
*
* @param \Magento\Framework\Setup\SchemaSetupInterface $setup
* @param \Magento\Framework\Setup\ModuleContextInterface $context
* @return void
*/
public function uninstall(
\Magento\Framework\Setup\SchemaSetupInterface $setup,
\Magento\Framework\Setup\ModuleContextInterface $context
) {
$setup->startSetup();
// Uninstall logic here
$setup->endSetup();
}
}
Uygun yöntemleri kullanarak tabloları, sütunları veya verileri kaldırın. Bkz \Magento\Framework\DB\Adapter\AdapterInterfacegibi kullanılabilen $setup->getConnection().