Piwik\Plugins\Installation\Controller::tablesCreation PHP Method

tablesCreation() public method

Installation Step 4: Table Creation
public tablesCreation ( )
    function tablesCreation()
    {
        $this->checkPiwikIsNotInstalled();
        $view = new View('@Installation/tablesCreation', $this->getInstallationSteps(), __FUNCTION__);
        if ($this->getParam('deleteTables')) {
            Manager::getInstance()->clearPluginsInstalledConfig();
            Db::dropAllTables();
            $view->existingTablesDeleted = true;
        }
        $tablesInstalled = DbHelper::getTablesInstalled();
        $view->tablesInstalled = '';
        if (count($tablesInstalled) > 0) {
            // we have existing tables
            $view->tablesInstalled = implode(', ', $tablesInstalled);
            $view->someTablesInstalled = true;
            $self = $this;
            Access::doAsSuperUser(function () use($self, $tablesInstalled, $view) {
                Access::getInstance();
                if ($self->hasEnoughTablesToReuseDb($tablesInstalled) && count(APISitesManager::getInstance()->getAllSitesId()) > 0 && count(APIUsersManager::getInstance()->getUsers()) > 0) {
                    $view->showReuseExistingTables = true;
                }
            });
        } else {
            DbHelper::createTables();
            DbHelper::createAnonymousUser();
            $this->updateComponents();
            Updater::recordComponentSuccessfullyUpdated('core', Version::VERSION);
            $view->tablesCreated = true;
            $view->showNextStep = true;
        }
        return $view->render();
    }