/** * @param string $shortcut * * @return Bookmark */ private function insertBookmark($shortcut) { $bm = new Bookmark(); $bm->shortcut = $shortcut; $bm->command = 'command for ' . $shortcut; $bm->description = 'description for ' . $shortcut; $bm->save(); return $bm; }
protected function execute(InputInterface $input, OutputInterface $output) { $bookmark = new Bookmark(); $bookmark->command = $input->getArgument('cmd'); $bookmark->shortcut = $input->getArgument('shortcut'); $bookmark->description = $input->getOption('description'); $bookmark->save(); $output->writeln(' Shortcut: ' . $bookmark->shortcut); $output->writeln(' Command: ' . $bookmark->command); $output->writeln('Description: ' . $bookmark->description); $this->out->success('Bookmark added.'); }
/** * @param array $map */ private function importMap($map) { $bookmark = new Bookmark(); $bookmark->hydrate($map); $existing = Bookmark::select()->where('shortcut', $bookmark->shortcut)->one(); if ($existing !== null) { $bookmark->setExtra('Existing command', $existing->command); $this->skipped[] = $bookmark; return; } try { $bookmark->save(); $this->imported[] = $bookmark; } catch (\Exception $e) { $bookmark->setExtra('Error', $e->getMessage()); $this->failed[] = $bookmark; } }