public function testIfWillGetBuildInformationWithModelParam() { $cmd = new Command(new ModelWithSecondConnection()); $info = $cmd->buildinfo(); $this->assertTrue(array_key_exists('version', $info)); $cmd = new Command(new SimplePrimaryKey()); $info = $cmd->buildinfo(); $this->assertTrue(array_key_exists('version', $info)); }
public function call($command, $arguments = []) { if ($this->isAvailable($command)) { try { return parent::call($command, $arguments); } catch (CommandNotFoundException $e) { $this->available->{$command} = false; } } }
public function generate() { $destName = (new ReflectionClass(\Maslosoft\Mangan\Traits\AvailableCommands::class))->getFileName(); $srcName = $destName . 's'; $view = new MiniView($this); $cmd = new Command(); $commands = $cmd->listCommands()['commands']; $functions = []; foreach ($commands as $name => $cmdData) { if ($cmdData['adminOnly']) { continue; } $functions[] = $view->render('command', ['mongoName' => $name, 'name' => $this->_sanitize($name), 'help' => explode("\n", $cmdData['help'])], true); } $src = file_get_contents($srcName); $code = implode("\n", $functions) . "\n}"; $result = str_replace('}', $code, $src); file_put_contents($destName, $result); }