ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
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 ()
 
 outputInObjective ()
 
 showLastObjectiveLabel ()
 

Protected Attributes

InputInterface $in
 
OutputInterface $out
 
SymfonyStyle $style
 
bool $last_objective_was_notable = false
 
string $last_objective_label = ""
 
bool $output_in_objective = false
 

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 44 of file IOWrapper.php.

45 {
46 $this->in = $in;
47 $this->out = $out;
48 $this->style = new SymfonyStyle($in, $out);
49 }
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 57 of file IOWrapper.php.

57 : void
58 {
59 $this->style->progressAdvance();
60 }

◆ confirmExplicit()

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

Implements ILIAS\Setup\AdminInteraction.

Definition at line 73 of file IOWrapper.php.

73 : bool
74 {
75 $this->outputInObjective();
76 if (!$this->shouldSayYes()) {
77 return $this->style->ask(
79 null,
80 fn (string $input): bool => $type_text_to_confirm === $input
81 );
82 } else {
83 $this->inform("Automatically confirmed:\n\n$message");
84 return true;
85 }
86 }
inform(string $message)
Definition: IOWrapper.php:67
$message
Definition: xapiexit.php:31

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 88 of file IOWrapper.php.

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

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 129 of file IOWrapper.php.

129 : void
130 {
131 $this->style->error($text);
132 }

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 160 of file IOWrapper.php.

160 : void
161 {
162 // Always show label of failed objectives.
163 if ($this->output_in_objective || !$this->last_objective_was_notable) {
164 $this->startObjective($this->last_objective_label, true);
165 }
166
167 if ($this->showLastObjectiveLabel()) {
168 $this->style->write("[<fg=red>FAILED</>]\n");
169 }
170 }
startObjective(string $label, bool $is_notable)
Definition: IOWrapper.php:139

References 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 149 of file IOWrapper.php.

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

References 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 67 of file IOWrapper.php.

67 : void
68 {
69 $this->outputInObjective();
70 $this->style->note($message);
71 }

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\runMigration().

+ 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 187 of file IOWrapper.php.

187 : bool
188 {
189 return $this->out->isVerbose();
190 }

◆ outputInObjective()

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

Definition at line 172 of file IOWrapper.php.

172 : void
173 {
174 if (!$this->output_in_objective && $this->showLastObjectiveLabel()) {
175 $this->output_in_objective = true;
176 $this->style->write("[in progress]\n");
177 }
178 }

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 101 of file IOWrapper.php.

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

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 114 of file IOWrapper.php.

114 : bool
115 {
116 return $this->in->getOption("yes") ?? false;
117 }

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 180 of file IOWrapper.php.

180 : bool
181 {
182 return $this->last_objective_was_notable
183 || $this->out->isVeryVerbose()
184 || $this->out->isDebug();
185 }

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 139 of file IOWrapper.php.

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

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 52 of file IOWrapper.php.

52 : void
53 {
54 $this->style->progressStart($max);
55 }

◆ stopProgress()

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

Implements ILIAS\Setup\AdminInteraction.

Definition at line 62 of file IOWrapper.php.

62 : void
63 {
64 $this->style->progressFinish();
65 }

◆ success()

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

Definition at line 124 of file IOWrapper.php.

124 : void
125 {
126 $this->style->success($text);
127 }

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 134 of file IOWrapper.php.

134 : void
135 {
136 $this->style->text($text);
137 }

Referenced by ILIAS\Setup\CLI\MigrateCommand\listMigrations(), ILIAS\Setup\CLI\IOWrapper\printLicenseMessage(), 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 119 of file IOWrapper.php.

119 : void
120 {
121 $this->style->title($title);
122 }

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 = false
protected

Definition at line 42 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: