/** * Shows support info for all or specified setting(s) * * @param null|string $key Key/name of a specific setting. Leave empty for * all settings. */ public function showSupportedSettings($key = null) { $settings = array(); if ($key !== null && isset($this->supportedSettings[$key])) { $settings[$key] = $this->supportedSettings[$key]; } else { $settings = $this->supportedSettings; } $currentSettings = Setting::select()->in('key', array_keys($settings))->all(); $out = $this->client->getOutput(); $out->section('Supported settings [default]'); foreach ($settings as $key => $info) { $out->write($key); if (isset($currentSettings[$key])) { $out->write(' = ' . $currentSettings[$key]->value); } if (isset($info['default'])) { $out->write(' [' . $info['default'] . ']'); } $out->newLine(); $out->writeln($info['desc']); $out->newLine(); } }
private function saveDatabaseVersion() { $this->client->setSetting(Settings::DATABASE_VERSION, Client::FF_VERSION); }
<?php use phparsenal\fastforward\Client; require __DIR__ . DIRECTORY_SEPARATOR . 'vendor/autoload.php'; // Replace the path to *this* PHP file with the alias because the usage summary // relies on this. if ($argc > 0) { $argv[0] = 'ff'; } $client = new Client('fast-forward', Client::FF_VERSION); $client->init(); try { $client->run(); } catch (\Exception $e) { $msg = array($e->getMessage(), $e->getTraceAsString()); $client->getOutput()->error($msg); }
/** * This method is called before the first test of this test class is run. * * @since Method available since Release 3.4.0 */ public static function setUpBeforeClass() { $stream = new StreamOutput(fopen('php://memory', 'w', false)); self::$client = new Client(); self::$client->init($stream, ':memory:'); }
/** * @param Client $client * * @return $this */ public function sortAndLimit($client) { // Make sure we have a valid column to sort by $sortColumn = $client->getSetting(Settings::SORT); $columnMap = $this->toAssoc(); if (!isset($columnMap[$sortColumn])) { $sortColumn = 'hit_count'; } // Large hit counts and latest time stamps come first if ($sortColumn === 'hit_count' || substr($sortColumn, 0, 3) === 'ts_') { $this->orderDesc($sortColumn); } else { $this->orderAsc($sortColumn); } // Only limit when set $maxRows = $client->getSetting(Settings::LIMIT); if ($maxRows > 0) { $this->limit($maxRows); } return $this; }