public function Debugger::writeTitle in Acquia Purge 8
Write a header title.
Parameters
string $title: Title to render in the center of the string buffer.
bool $top: Whether to include a top separator line.
bool $bottom: Whether to include a bottom separator line.
Throws
\LogicException Thrown when the debugger isn't enabled.
Overrides DebuggerInterface::writeTitle
1 call to Debugger::writeTitle()
- Debugger::writeTable in src/
Plugin/ Purge/ Purger/ Debugger.php - Write tabular data rendered as table to Drupal's debug output.
File
- src/
Plugin/ Purge/ Purger/ Debugger.php, line 292
Class
- Debugger
- Provides a centralized debugger for Acquia purger plugins.
Namespace
Drupal\acquia_purge\Plugin\Purge\PurgerCode
public function writeTitle($title, $top = TRUE, $bottom = TRUE) {
if (!$this->enabled) {
throw new \LogicException("Cannot call ::writeTitle().");
}
if ($top) {
$this
->writeSeparator('-');
}
$workspace = self::OUTPUT_BUFLEN - $this
->indentationDepth();
$left = intval(floor($workspace / 2) - ceil(strlen($title) / 2) - 1);
$right = $workspace - $left - strlen($title) - 2;
$padleft = str_repeat(' ', $left);
$padright = str_repeat(' ', $right);
$this
->write('|' . $padleft . $title . $padright . '|');
if ($bottom) {
$this
->writeSeparator('-');
}
}