/** * Execute this command. * * @return int|void */ protected function doExecute() { $model = new ProfilesModel(); $profiles = $model->getItems(); $this->out(); foreach ($profiles as $profile) { $this->out(($profile->is_current ? '*' : ' ') . ' ', false); $this->out($profile->title); } return true; }
/** * checkout * * @param $profile * * @return bool * @throws \Exception */ public function checkout($profile) { $listModel = new ProfilesModel(); $profiles = $listModel->getList(); if (!in_array($profile, $profiles)) { throw new \Exception(sprintf('Profile "%s" not exists.', $name)); } $profileConfig = new Registry(); $file = JPATH_ROOT . '/tmp/sqlsync/config.yml'; $profileConfig->loadFile($file); $profileConfig->set('profile', $profile); $content = $profileConfig->toString('yaml'); if (!\JFile::write($file, $content)) { throw new \Exception('Writing profile config fail.'); } return true; }