ILIAS  release_7 Revision v7.30-3-g800a261c036
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

 $in
 
 $out
 
 $style
 
 $last_objective_was_notable = false
 
 $last_objective_label = ""
 
 $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 16 of file IOWrapper.php.

Constructor & Destructor Documentation

◆ __construct()

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

Definition at line 51 of file IOWrapper.php.

52 {
53 $this->in = $in;
54 $this->out = $out;
55 $this->style = new SymfonyStyle($in, $out);
56 }

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

64 : void
65 {
66 $this->style->progressAdvance();
67 }

◆ confirmExplicit()

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

Implements ILIAS\Setup\AdminInteraction.

Definition at line 80 of file IOWrapper.php.

80 : bool
81 {
82 $this->outputInObjective();
83 if (!$this->shouldSayYes()) {
84 return $this->style->ask(
86 null,
87 function (string $input) use ($type_text_to_confirm) : bool {
88 return $type_text_to_confirm === $input;
89 }
90 );
91 } else {
92 $this->inform("Automatically confirmed:\n\n$message");
93 return true;
94 }
95 }
inform(string $message)
Definition: IOWrapper.php:74
$message
Definition: xapiexit.php:14

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

97 : bool
98 {
99 $this->outputInObjective();
100 if (!$this->shouldSayYes()) {
101 return $this->style->confirm($message, false);
102 } else {
103 $this->inform("Automatically confirmed:\n\n$message");
104 return true;
105 }
106 }

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

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

Referenced by ILIAS\Setup\CLI\MigrateCommand\runMigration().

+ Here is the caller graph for this function:

◆ failedLastObjective()

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

Definition at line 169 of file IOWrapper.php.

170 {
171 // Always show label of failed objectives.
172 if ($this->output_in_objective || !$this->last_objective_was_notable) {
173 $this->startObjective($this->last_objective_label, true);
174 }
175
176 if ($this->showLastObjectiveLabel()) {
177 $this->style->write("[<fg=red>FAILED</>]\n");
178 }
179 }
startObjective(string $label, bool $is_notable)
Definition: IOWrapper.php:148

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

159 {
160 if ($this->output_in_objective) {
161 $this->startObjective($this->last_objective_label, $this->last_objective_was_notable);
162 }
163
164 if ($this->showLastObjectiveLabel()) {
165 $this->style->write("[<fg=green>OK</>]\n");
166 }
167 }

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

74 : void
75 {
76 $this->outputInObjective();
77 $this->style->note($message);
78 }

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

196 : bool
197 {
198 return $this->out->isVerbose();
199 }

◆ outputInObjective()

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

Definition at line 181 of file IOWrapper.php.

181 : void
182 {
183 if (!$this->output_in_objective && $this->showLastObjectiveLabel()) {
184 $this->output_in_objective = true;
185 $this->style->write("[in progress]\n");
186 }
187 }

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

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

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

123 : bool
124 {
125 return $this->in->getOption("yes") ?? false;
126 }

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

190 {
191 return $this->last_objective_was_notable
192 || $this->out->isVeryVerbose()
193 || $this->out->isDebug();
194 }

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

149 {
150 $this->last_objective_was_notable = $is_notable;
151 $this->last_objective_label = $label;
152 $this->output_in_objective = false;
153 if ($this->showLastObjectiveLabel()) {
154 $this->style->write(str_pad($label . "...", self::LABEL_WIDTH));
155 }
156 }

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

59 : void
60 {
61 $this->style->progressStart($max);
62 }

◆ stopProgress()

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

Implements ILIAS\Setup\AdminInteraction.

Definition at line 69 of file IOWrapper.php.

69 : void
70 {
71 $this->style->progressFinish();
72 }

◆ success()

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

Definition at line 133 of file IOWrapper.php.

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

◆ text()

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

Definition at line 143 of file IOWrapper.php.

143 : void
144 {
145 $this->style->text($text);
146 }

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

128 : void
129 {
130 $this->style->title($title);
131 }

Field Documentation

◆ $in

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

Definition at line 24 of file IOWrapper.php.

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

◆ $last_objective_label

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

Definition at line 44 of file IOWrapper.php.

◆ $last_objective_was_notable

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

Definition at line 39 of file IOWrapper.php.

◆ $out

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

Definition at line 29 of file IOWrapper.php.

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

◆ $output_in_objective

ILIAS\Setup\CLI\IOWrapper::$output_in_objective = false
protected

Definition at line 49 of file IOWrapper.php.

◆ $style

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

Definition at line 34 of file IOWrapper.php.

◆ ELLIPSIS

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

Definition at line 19 of file IOWrapper.php.

◆ LABEL_WIDTH

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

Definition at line 18 of file IOWrapper.php.


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