ILIAS  trunk Revision v13.0_alpha-62-g3b72d83f2e5
ILIAS\Setup\CLI\IOWrapper Class Reference

Wrapper around symfonies input and output facilities to provide just the functionality required for the ILIAS-setup. More...

+ Inheritance diagram for ILIAS\Setup\CLI\IOWrapper:
+ Collaboration diagram for ILIAS\Setup\CLI\IOWrapper:

Public Member Functions

 __construct (InputInterface $in, OutputInterface $out)
 
 startProgress (int $max)
 
 advanceProgress ()
 
 stopProgress ()
 
 inform (string $message)
 
 confirmExplicit (string $message, string $type_text_to_confirm)
 
 confirmOrDeny (string $message)
 
 printLicenseMessage ()
 
 title (string $title)
 
 success (string $text)
 
 error (string $text)
 
 text (string $text)
 
 startObjective (string $label, bool $is_notable)
 
 finishedLastObjective ()
 
 failedLastObjective ()
 
 isVerbose ()
 
 startProgress (int $max)
 
 advanceProgress ()
 
 stopProgress ()
 
 inform (string $message)
 
 confirmOrDeny (string $message)
 
 confirmExplicit (string $message, string $type_text_to_confirm)
 

Data Fields

const LABEL_WIDTH = 75
 
const ELLIPSIS = "..."
 

Protected Member Functions

 shouldSayYes ()
 
 closeLastObjective ()
 The line of the last objective is complete, output from now on does not belong to it and must not be marked as "[in progress]". More...
 
 outputInObjective ()
 
 showLastObjectiveLabel ()
 

Protected Attributes

InputInterface $in
 
OutputInterface $out
 
SymfonyStyle $style
 
bool $last_objective_was_notable = false
 
string $last_objective_label = ""
 
bool $output_in_objective = true
 true as long as there is no line of an objective waiting for its result More...
 

Detailed Description

Wrapper around symfonies input and output facilities to provide just the functionality required for the ILIAS-setup.

Definition at line 32 of file IOWrapper.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\Setup\CLI\IOWrapper::__construct ( InputInterface  $in,
OutputInterface  $out 
)

Definition at line 47 of file IOWrapper.php.

48 {
49 $this->in = $in;
50 $this->out = $out;
51 $this->style = new SymfonyStyle($in, $out);
52 }
OutputInterface $out
Definition: IOWrapper.php:38
InputInterface $in
Definition: IOWrapper.php:37

References ILIAS\Setup\CLI\IOWrapper\$in, and ILIAS\Setup\CLI\IOWrapper\$out.

Member Function Documentation

◆ advanceProgress()

ILIAS\Setup\CLI\IOWrapper::advanceProgress ( )

Implements ILIAS\Setup\AdminInteraction.

Definition at line 60 of file IOWrapper.php.

60 : void
61 {
62 $this->style->progressAdvance();
63 }

◆ closeLastObjective()

ILIAS\Setup\CLI\IOWrapper::closeLastObjective ( )
protected

The line of the last objective is complete, output from now on does not belong to it and must not be marked as "[in progress]".

Definition at line 181 of file IOWrapper.php.

181 : void
182 {
183 $this->output_in_objective = true;
184 }

Referenced by ILIAS\Setup\CLI\IOWrapper\failedLastObjective(), and ILIAS\Setup\CLI\IOWrapper\finishedLastObjective().

+ Here is the caller graph for this function:

◆ confirmExplicit()

ILIAS\Setup\CLI\IOWrapper::confirmExplicit ( string  $message,
string  $type_text_to_confirm 
)

Implements ILIAS\Setup\AdminInteraction.

Definition at line 76 of file IOWrapper.php.

76 : bool
77 {
78 $this->outputInObjective();
79 if (!$this->shouldSayYes()) {
80 return $this->style->ask(
82 null,
83 fn(string $input): bool => $type_text_to_confirm === $input
84 );
85 } else {
86 $this->inform("Automatically confirmed:\n\n$message");
87 return true;
88 }
89 }
inform(string $message)
Definition: IOWrapper.php:70

References $message, ILIAS\Setup\CLI\IOWrapper\inform(), ILIAS\Setup\CLI\IOWrapper\outputInObjective(), and ILIAS\Setup\CLI\IOWrapper\shouldSayYes().

+ Here is the call graph for this function:

◆ confirmOrDeny()

ILIAS\Setup\CLI\IOWrapper::confirmOrDeny ( string  $message)

Implements ILIAS\Setup\AdminInteraction.

Definition at line 91 of file IOWrapper.php.

91 : bool
92 {
93 $this->outputInObjective();
94 if (!$this->shouldSayYes()) {
95 return $this->style->confirm($message, false);
96 } else {
97 $this->inform("Automatically confirmed:\n\n$message");
98 return true;
99 }
100 }

References $message, ILIAS\Setup\CLI\IOWrapper\inform(), ILIAS\Setup\CLI\IOWrapper\outputInObjective(), and ILIAS\Setup\CLI\IOWrapper\shouldSayYes().

+ Here is the call graph for this function:

◆ error()

ILIAS\Setup\CLI\IOWrapper::error ( string  $text)

Definition at line 132 of file IOWrapper.php.

132 : void
133 {
134 $this->style->error($text);
135 }
$text
Definition: xapiexit.php:21

References $text.

Referenced by ILIAS\Setup\CLI\AchieveCommand\executeAchieveObjective(), and ILIAS\Setup\CLI\MigrateCommand\runMigration().

+ Here is the caller graph for this function:

◆ failedLastObjective()

ILIAS\Setup\CLI\IOWrapper::failedLastObjective ( )

Definition at line 164 of file IOWrapper.php.

164 : void
165 {
166 // Always show label of failed objectives.
167 if ($this->output_in_objective || !$this->last_objective_was_notable) {
168 $this->startObjective($this->last_objective_label, true);
169 }
170
171 if ($this->showLastObjectiveLabel()) {
172 $this->style->write("[<fg=red>FAILED</>]\n");
173 }
174 $this->closeLastObjective();
175 }
closeLastObjective()
The line of the last objective is complete, output from now on does not belong to it and must not be ...
Definition: IOWrapper.php:181
startObjective(string $label, bool $is_notable)
Definition: IOWrapper.php:142

References ILIAS\Setup\CLI\IOWrapper\closeLastObjective(), ILIAS\Setup\CLI\IOWrapper\showLastObjectiveLabel(), and ILIAS\Setup\CLI\IOWrapper\startObjective().

+ Here is the call graph for this function:

◆ finishedLastObjective()

ILIAS\Setup\CLI\IOWrapper::finishedLastObjective ( )

Definition at line 152 of file IOWrapper.php.

152 : void
153 {
154 if ($this->output_in_objective) {
155 $this->startObjective($this->last_objective_label, $this->last_objective_was_notable);
156 }
157
158 if ($this->showLastObjectiveLabel()) {
159 $this->style->write("[<fg=green>OK</>]\n");
160 }
161 $this->closeLastObjective();
162 }

References ILIAS\Setup\CLI\IOWrapper\closeLastObjective(), ILIAS\Setup\CLI\IOWrapper\showLastObjectiveLabel(), and ILIAS\Setup\CLI\IOWrapper\startObjective().

+ Here is the call graph for this function:

◆ inform()

ILIAS\Setup\CLI\IOWrapper::inform ( string  $message)

Implements ILIAS\Setup\AdminInteraction.

Definition at line 70 of file IOWrapper.php.

70 : void
71 {
72 $this->outputInObjective();
73 $this->style->note($message);
74 }

References $message, and ILIAS\Setup\CLI\IOWrapper\outputInObjective().

Referenced by ILIAS\Setup\CLI\IOWrapper\confirmExplicit(), ILIAS\Setup\CLI\IOWrapper\confirmOrDeny(), ILIAS\Setup\CLI\MigrateCommand\listMigrations(), and ILIAS\Setup\CLI\MigrateCommand\runAllMigrations().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isVerbose()

ILIAS\Setup\CLI\IOWrapper::isVerbose ( )

Definition at line 201 of file IOWrapper.php.

201 : bool
202 {
203 return $this->out->isVerbose();
204 }

◆ outputInObjective()

ILIAS\Setup\CLI\IOWrapper::outputInObjective ( )
protected

Definition at line 186 of file IOWrapper.php.

186 : void
187 {
188 if (!$this->output_in_objective && $this->showLastObjectiveLabel()) {
189 $this->output_in_objective = true;
190 $this->style->write("[in progress]\n");
191 }
192 }

References ILIAS\Setup\CLI\IOWrapper\showLastObjectiveLabel().

Referenced by ILIAS\Setup\CLI\IOWrapper\confirmExplicit(), ILIAS\Setup\CLI\IOWrapper\confirmOrDeny(), and ILIAS\Setup\CLI\IOWrapper\inform().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ printLicenseMessage()

ILIAS\Setup\CLI\IOWrapper::printLicenseMessage ( )

Definition at line 104 of file IOWrapper.php.

104 : void
105 {
106 if ($this->shouldSayYes() || ($this->in->hasOption("no-interaction") && $this->in->getOption("no-interaction"))) {
107 return;
108 }
109 $this->text(
110 " ILIAS Copyright (C) 1998-2019 ILIAS Open Source e.V. - GPLv3\n\n" .
111 "This program comes with ABSOLUTELY NO WARRANTY. This is free software,\n" .
112 "and you are welcome to redistribute it under certain conditions. Look\n" .
113 "into the LICENSE file for details."
114 );
115 }

References ILIAS\Setup\CLI\IOWrapper\shouldSayYes(), and ILIAS\Setup\CLI\IOWrapper\text().

+ Here is the call graph for this function:

◆ shouldSayYes()

ILIAS\Setup\CLI\IOWrapper::shouldSayYes ( )
protected

Definition at line 117 of file IOWrapper.php.

117 : bool
118 {
119 return $this->in->getOption("yes") ?? false;
120 }

Referenced by ILIAS\Setup\CLI\IOWrapper\confirmExplicit(), ILIAS\Setup\CLI\IOWrapper\confirmOrDeny(), and ILIAS\Setup\CLI\IOWrapper\printLicenseMessage().

+ Here is the caller graph for this function:

◆ showLastObjectiveLabel()

ILIAS\Setup\CLI\IOWrapper::showLastObjectiveLabel ( )
protected

Definition at line 194 of file IOWrapper.php.

194 : bool
195 {
196 return $this->last_objective_was_notable
197 || $this->out->isVeryVerbose()
198 || $this->out->isDebug();
199 }

Referenced by ILIAS\Setup\CLI\IOWrapper\failedLastObjective(), ILIAS\Setup\CLI\IOWrapper\finishedLastObjective(), ILIAS\Setup\CLI\IOWrapper\outputInObjective(), and ILIAS\Setup\CLI\IOWrapper\startObjective().

+ Here is the caller graph for this function:

◆ startObjective()

ILIAS\Setup\CLI\IOWrapper::startObjective ( string  $label,
bool  $is_notable 
)

Definition at line 142 of file IOWrapper.php.

142 : void
143 {
144 $this->last_objective_was_notable = $is_notable;
145 $this->last_objective_label = $label;
146 $this->output_in_objective = false;
147 if ($this->showLastObjectiveLabel()) {
148 $this->style->write(str_pad($label . "...", self::LABEL_WIDTH));
149 }
150 }

References ILIAS\Setup\CLI\IOWrapper\showLastObjectiveLabel().

Referenced by ILIAS\Setup\CLI\IOWrapper\failedLastObjective(), and ILIAS\Setup\CLI\IOWrapper\finishedLastObjective().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ startProgress()

ILIAS\Setup\CLI\IOWrapper::startProgress ( int  $max)

Implements ILIAS\Setup\AdminInteraction.

Definition at line 55 of file IOWrapper.php.

55 : void
56 {
57 $this->style->progressStart($max);
58 }

◆ stopProgress()

ILIAS\Setup\CLI\IOWrapper::stopProgress ( )

Implements ILIAS\Setup\AdminInteraction.

Definition at line 65 of file IOWrapper.php.

65 : void
66 {
67 $this->style->progressFinish();
68 }

◆ success()

ILIAS\Setup\CLI\IOWrapper::success ( string  $text)

Definition at line 127 of file IOWrapper.php.

127 : void
128 {
129 $this->style->success($text);
130 }

References $text.

Referenced by ILIAS\Setup\CLI\AchieveCommand\executeAchieveObjective().

+ Here is the caller graph for this function:

◆ text()

ILIAS\Setup\CLI\IOWrapper::text ( string  $text)

Definition at line 137 of file IOWrapper.php.

137 : void
138 {
139 $this->style->text($text);
140 }

References $text.

Referenced by ILIAS\Setup\CLI\MigrateCommand\listMigrations(), ILIAS\Setup\CLI\IOWrapper\printLicenseMessage(), ILIAS\Setup\CLI\MigrateCommand\runAllMigrations(), and ILIAS\Setup\CLI\MigrateCommand\runMigration().

+ Here is the caller graph for this function:

◆ title()

ILIAS\Setup\CLI\IOWrapper::title ( string  $title)

Definition at line 122 of file IOWrapper.php.

122 : void
123 {
124 $this->style->title($title);
125 }

Referenced by ILIAS\Setup\CLI\AchieveCommand\executeAchieveObjective(), and ILIAS\Setup\CLI\AchieveCommand\executeListNamedObjectives().

+ Here is the caller graph for this function:

Field Documentation

◆ $in

InputInterface ILIAS\Setup\CLI\IOWrapper::$in
protected

Definition at line 37 of file IOWrapper.php.

Referenced by ILIAS\Setup\CLI\IOWrapper\__construct().

◆ $last_objective_label

string ILIAS\Setup\CLI\IOWrapper::$last_objective_label = ""
protected

Definition at line 41 of file IOWrapper.php.

◆ $last_objective_was_notable

bool ILIAS\Setup\CLI\IOWrapper::$last_objective_was_notable = false
protected

Definition at line 40 of file IOWrapper.php.

◆ $out

OutputInterface ILIAS\Setup\CLI\IOWrapper::$out
protected

Definition at line 38 of file IOWrapper.php.

Referenced by ILIAS\Setup\CLI\IOWrapper\__construct().

◆ $output_in_objective

bool ILIAS\Setup\CLI\IOWrapper::$output_in_objective = true
protected

true as long as there is no line of an objective waiting for its result

Definition at line 45 of file IOWrapper.php.

◆ $style

SymfonyStyle ILIAS\Setup\CLI\IOWrapper::$style
protected

Definition at line 39 of file IOWrapper.php.

◆ ELLIPSIS

const ILIAS\Setup\CLI\IOWrapper::ELLIPSIS = "..."

Definition at line 35 of file IOWrapper.php.

◆ LABEL_WIDTH

const ILIAS\Setup\CLI\IOWrapper::LABEL_WIDTH = 75

The documentation for this class was generated from the following file: