-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move checkbox list to a trait for re-use
- Loading branch information
1 parent
ce12834
commit 68afc38
Showing
2 changed files
with
51 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?php namespace BennoThommo\OctoberCli\Traits; | ||
|
||
use Symfony\Component\Console\Output\OutputInterface; | ||
|
||
trait CheckboxList | ||
{ | ||
/** @var OutputInterface Output interface */ | ||
protected $output; | ||
|
||
/** | ||
* Writes out a checkbox item to console. | ||
* | ||
* @param [type] $text | ||
* @return void | ||
*/ | ||
protected function doCheck($text) | ||
{ | ||
$this->section = $this->output->section(); | ||
$this->sectionText = $text; | ||
$this->section->writeln('[ ] ' . $text); | ||
} | ||
|
||
protected function checkFailed() | ||
{ | ||
$this->section->overwrite('[<error>X</error>] ' . $this->sectionText); | ||
if (func_num_args() > 0) { | ||
$this->section->writeln("<comment> " . implode("\n ", func_get_args()) . '</comment>'); | ||
} | ||
$this->failed = true; | ||
} | ||
|
||
protected function checkWarned() | ||
{ | ||
$this->section->overwrite('[<warn>W</warn>] ' . $this->sectionText); | ||
if (func_num_args() > 0) { | ||
$this->section->writeln("<comment> " . implode("\n ", func_get_args()) . '</comment>'); | ||
} | ||
$this->warned = true; | ||
} | ||
|
||
protected function checkSuccessful() | ||
{ | ||
$this->section->overwrite('[<success>✓</success>] ' . $this->sectionText); | ||
if (func_num_args() > 0) { | ||
$this->section->writeln("<comment> " . implode("\n ", func_get_args()) . '</comment>'); | ||
} | ||
} | ||
} |