|
Apache/2.4.41 (Ubuntu) Linux vmi616275.contaboserver.net 5.4.0-84-generic #94-Ubuntu SMP Thu Aug 26 20:27:37 UTC 2021 x86_64 uid=33(www-data) gid=33(www-data) groups=33(www-data) server ip : 62.171.164.128 | your ip : 127.0.0.1 safemode OFF > / home / dev2.destoffenstraat.com / setup / src / Magento / Setup / Console / Command / |
Filename | /home/dev2.destoffenstraat.com/setup/src/Magento/Setup/Console/Command/AbstractModuleCommand.php |
Size | 3.26 kb |
Permission | rw-r--r-- |
Owner | root : root |
Create time | 17-Aug-2025 10:26 |
Last modified | 28-Jan-2025 06:45 |
Last accessed | 23-Aug-2025 03:55 |
Actions | edit | rename | delete | download (gzip) |
View | text | code | image |
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Setup\Console\Command;
use Magento\Framework\ObjectManagerInterface;
use Magento\Setup\Model\ObjectManagerProvider;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
/**
* Abstract class for Enable and Disable commands to consolidate common logic
*/
abstract class AbstractModuleCommand extends AbstractSetupCommand
{
/**
* Names of input arguments or options
*/
const INPUT_KEY_MODULES = 'module';
const INPUT_KEY_CLEAR_STATIC_CONTENT = 'clear-static-content';
/**
* Object manager
*
* @var ObjectManagerInterface
*/
protected $objectManager;
/**
* Inject dependencies
*
* @param ObjectManagerProvider $objectManagerProvider
*/
public function __construct(ObjectManagerProvider $objectManagerProvider)
{
$this->objectManager = $objectManagerProvider->get();
parent::__construct();
}
/**
* {@inheritdoc}
*/
protected function configure()
{
$this->addArgument(
self::INPUT_KEY_MODULES,
InputArgument::IS_ARRAY | ($this->isModuleRequired() ? InputArgument::REQUIRED : InputArgument::OPTIONAL),
'Name of the module'
);
$this->addOption(
self::INPUT_KEY_CLEAR_STATIC_CONTENT,
'c',
InputOption::VALUE_NONE,
'Clear generated static view files. Necessary, if the module(s) have static view files'
);
parent::configure();
}
/**
* Returns if module argument is required
*
* @return bool
*/
abstract protected function isModuleRequired();
/**
* Cleanup after updated modules status
*
* @param InputInterface $input
* @param OutputInterface $output
* @return void
*/
protected function cleanup(InputInterface $input, OutputInterface $output)
{
/** @var \Magento\Framework\App\Cache $cache */
$cache = $this->objectManager->get(\Magento\Framework\App\Cache::class);
$cache->clean();
$output->writeln('<info>Cache cleared successfully.</info>');
/** @var \Magento\Framework\App\State\CleanupFiles $cleanupFiles */
$cleanupFiles = $this->objectManager->get(\Magento\Framework\App\State\CleanupFiles::class);
$cleanupFiles->clearCodeGeneratedClasses();
$output->writeln(
"<info>Generated classes cleared successfully. Please run the 'setup:di:compile' command to "
. 'generate classes.</info>'
);
if ($input->getOption(self::INPUT_KEY_CLEAR_STATIC_CONTENT)) {
$cleanupFiles->clearMaterializedViewFiles();
$output->writeln('<info>Generated static view files cleared successfully.</info>');
} else {
$output->writeln(
"<info>Info: Some modules might require static view files to be cleared. To do this, run '"
. $this->getName() . "' with the --" . self::INPUT_KEY_CLEAR_STATIC_CONTENT
. ' option to clear them.</info>'
);
}
}
}
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Setup\Console\Command;
use Magento\Framework\ObjectManagerInterface;
use Magento\Setup\Model\ObjectManagerProvider;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
/**
* Abstract class for Enable and Disable commands to consolidate common logic
*/
abstract class AbstractModuleCommand extends AbstractSetupCommand
{
/**
* Names of input arguments or options
*/
const INPUT_KEY_MODULES = 'module';
const INPUT_KEY_CLEAR_STATIC_CONTENT = 'clear-static-content';
/**
* Object manager
*
* @var ObjectManagerInterface
*/
protected $objectManager;
/**
* Inject dependencies
*
* @param ObjectManagerProvider $objectManagerProvider
*/
public function __construct(ObjectManagerProvider $objectManagerProvider)
{
$this->objectManager = $objectManagerProvider->get();
parent::__construct();
}
/**
* {@inheritdoc}
*/
protected function configure()
{
$this->addArgument(
self::INPUT_KEY_MODULES,
InputArgument::IS_ARRAY | ($this->isModuleRequired() ? InputArgument::REQUIRED : InputArgument::OPTIONAL),
'Name of the module'
);
$this->addOption(
self::INPUT_KEY_CLEAR_STATIC_CONTENT,
'c',
InputOption::VALUE_NONE,
'Clear generated static view files. Necessary, if the module(s) have static view files'
);
parent::configure();
}
/**
* Returns if module argument is required
*
* @return bool
*/
abstract protected function isModuleRequired();
/**
* Cleanup after updated modules status
*
* @param InputInterface $input
* @param OutputInterface $output
* @return void
*/
protected function cleanup(InputInterface $input, OutputInterface $output)
{
/** @var \Magento\Framework\App\Cache $cache */
$cache = $this->objectManager->get(\Magento\Framework\App\Cache::class);
$cache->clean();
$output->writeln('<info>Cache cleared successfully.</info>');
/** @var \Magento\Framework\App\State\CleanupFiles $cleanupFiles */
$cleanupFiles = $this->objectManager->get(\Magento\Framework\App\State\CleanupFiles::class);
$cleanupFiles->clearCodeGeneratedClasses();
$output->writeln(
"<info>Generated classes cleared successfully. Please run the 'setup:di:compile' command to "
. 'generate classes.</info>'
);
if ($input->getOption(self::INPUT_KEY_CLEAR_STATIC_CONTENT)) {
$cleanupFiles->clearMaterializedViewFiles();
$output->writeln('<info>Generated static view files cleared successfully.</info>');
} else {
$output->writeln(
"<info>Info: Some modules might require static view files to be cleared. To do this, run '"
. $this->getName() . "' with the --" . self::INPUT_KEY_CLEAR_STATIC_CONTENT
. ' option to clear them.</info>'
);
}
}
}