public function fire()
{
$tables = $this->input->getOption('tables');
if ($tables == false) {
$this->error('Cannot find table name.');
}
$tables = explode(',', $tables);
if (count($tables) == 0) {
$this->error('Cannot find table name.');
}
$config = $this->databaseHandler->getConfig();
// 어떤 connection 에 table 이 있는지 알 수 없음
$connectors = [];
foreach ($config as $name => $settings) {
$connectors[] = $this->databaseHandler->connection($name);
}
$cacheNames = [];
/** @var \Xpressengine\Database\VirtualConnectionInterface $connector */
foreach ($connectors as $connector) {
foreach ($tables as $table) {
if (in_array($table, $cacheNames) === true) {
continue;
}
if ($connector->setSchemaCache($table, true) === true) {
$cacheNames[] = $table;
}
}
}
if (count($cacheNames) === 0) {
$this->error('Cannot find table name. Please check database table name');
} else {
$this->info(implode(',', array_unique($cacheNames)) . ' database tables cached.');
}
}