Created
July 29, 2017 11:02
-
-
Save pankajlele/4fe3aa7cb76bff15ce2881ed6df0fe22 to your computer and use it in GitHub Desktop.
This trait can be used to write console output from service classes.
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
<?php | |
namespace Yout\Package\Command; | |
/* | |
* This script belongs to the Flow package "Your.Package". | |
*/ | |
use TYPO3\Flow\Cli\ConsoleOutput; | |
/** | |
* A trait to add ConsoleOutput functionality to other service classes | |
*/ | |
trait ConsoleOutputTrait | |
{ | |
/** | |
* @var ConsoleOutput | |
*/ | |
protected $consoleOutput = null; | |
/** | |
* Console output | |
* | |
* @param ConsoleOutput $consoleOutput | |
*/ | |
public function setConsoleOutput(ConsoleOutput $consoleOutput) | |
{ | |
$this->consoleOutput = $consoleOutput; | |
} | |
/** | |
* Writes line to console output | |
* | |
* This function does nothing in Web context | |
* | |
* @param $text | |
* @param array $arguments | |
*/ | |
protected function consoleOutputLine($text, $arguments = []) | |
{ | |
if ($this->consoleOutput !== null && FLOW_SAPITYPE === 'CLI') { | |
$this->consoleOutput->outputLine($text, $arguments); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment