Airship\Cabin\Bridge\Landing\Admin::saveDatabase PHP Method

saveDatabase() protected method

Write the updated JSON configuration file.
protected saveDatabase ( array $post = [], array $old = [] ) : boolean
$post array
$old array
return boolean
    protected function saveDatabase(array $post = [], array $old = []) : bool
    {
        $twigEnv = \Airship\configWriter(ROOT . '/config/templates');
        $databases = [];
        $filter = new DatabaseFilter();
        foreach ($post['db_keys'] as $index => $key) {
            foreach (\array_keys($post['database'][$index]) as $i) {
                if (empty($post['database'][$index][$i]['driver'])) {
                    unset($post['database'][$index][$i]);
                    continue;
                }
                $post['database'][$index][$i]['options'] = \json_decode($post['database'][$index][$i]['options'], true);
                if (empty($post['database'][$index][$i]['password'])) {
                    $post['database'][$index][$i]['password'] = (string) ($old[$key][$i]['password'] ?? '');
                }
            }
            if (!empty($post['database'][$index])) {
                $databases[$key] = $post['database'][$index];
            }
            $filter->addDatabaseFilters($key, \count($post['database'][$index]));
        }
        $databases = $filter($databases);
        return \file_put_contents(ROOT . '/config/databases.json', $twigEnv->render('databases.twig', ['databases' => $databases])) !== false;
    }