/**
* Checks whether connected database is empty or not.
*
* @param \Cake\Database\Connection $conn Database connection to use
* @return bool True if database if empty and tables can be imported, false if
* there are some existing tables
*/
public function isDbEmpty($conn)
{
$Folder = new Folder($this->config('schemaPath'));
$existingSchemas = $conn->schemaCollection()->listTables();
$newSchemas = array_map(function ($item) {
return Inflector::underscore(str_replace('Schema.php', '', $item));
}, $Folder->read()[1]);
$result = !array_intersect($existingSchemas, $newSchemas);
if (!$result) {
$this->error(__d('installer', 'A previous installation of QuickAppsCMS already exists, please drop your database tables before continue.'));
}
return $result;
}