You are here

class TableHelper in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 vendor/symfony/console/Helper/TableHelper.php \Symfony\Component\Console\Helper\TableHelper

Provides helpers to display table output.

@author Саша Стаменковић <umpirsky@gmail.com> @author Fabien Potencier <fabien@symfony.com>

Hierarchy

Expanded class hierarchy of TableHelper

Deprecated

since version 2.5, to be removed in 3.0 Use {@link Table} instead.

2 files declare their use of TableHelper
Application.php in vendor/symfony/console/Application.php
LegacyTableHelperTest.php in vendor/symfony/console/Tests/Helper/LegacyTableHelperTest.php

File

vendor/symfony/console/Helper/TableHelper.php, line 26

Namespace

Symfony\Component\Console\Helper
View source
class TableHelper extends Helper {
  const LAYOUT_DEFAULT = 0;
  const LAYOUT_BORDERLESS = 1;
  const LAYOUT_COMPACT = 2;

  /**
   * @var Table
   */
  private $table;
  public function __construct($triggerDeprecationError = true) {
    if ($triggerDeprecationError) {
      @trigger_error('The ' . __CLASS__ . ' class is deprecated since version 2.5 and will be removed in 3.0. Use the Symfony\\Component\\Console\\Helper\\Table class instead.', E_USER_DEPRECATED);
    }
    $this->table = new Table(new NullOutput());
  }

  /**
   * Sets table layout type.
   *
   * @param int $layout self::LAYOUT_*
   *
   * @return TableHelper
   *
   * @throws \InvalidArgumentException when the table layout is not known
   */
  public function setLayout($layout) {
    switch ($layout) {
      case self::LAYOUT_BORDERLESS:
        $this->table
          ->setStyle('borderless');
        break;
      case self::LAYOUT_COMPACT:
        $this->table
          ->setStyle('compact');
        break;
      case self::LAYOUT_DEFAULT:
        $this->table
          ->setStyle('default');
        break;
      default:
        throw new \InvalidArgumentException(sprintf('Invalid table layout "%s".', $layout));
    }
    return $this;
  }
  public function setHeaders(array $headers) {
    $this->table
      ->setHeaders($headers);
    return $this;
  }
  public function setRows(array $rows) {
    $this->table
      ->setRows($rows);
    return $this;
  }
  public function addRows(array $rows) {
    $this->table
      ->addRows($rows);
    return $this;
  }
  public function addRow(array $row) {
    $this->table
      ->addRow($row);
    return $this;
  }
  public function setRow($column, array $row) {
    $this->table
      ->setRow($column, $row);
    return $this;
  }

  /**
   * Sets padding character, used for cell padding.
   *
   * @param string $paddingChar
   *
   * @return TableHelper
   */
  public function setPaddingChar($paddingChar) {
    $this->table
      ->getStyle()
      ->setPaddingChar($paddingChar);
    return $this;
  }

  /**
   * Sets horizontal border character.
   *
   * @param string $horizontalBorderChar
   *
   * @return TableHelper
   */
  public function setHorizontalBorderChar($horizontalBorderChar) {
    $this->table
      ->getStyle()
      ->setHorizontalBorderChar($horizontalBorderChar);
    return $this;
  }

  /**
   * Sets vertical border character.
   *
   * @param string $verticalBorderChar
   *
   * @return TableHelper
   */
  public function setVerticalBorderChar($verticalBorderChar) {
    $this->table
      ->getStyle()
      ->setVerticalBorderChar($verticalBorderChar);
    return $this;
  }

  /**
   * Sets crossing character.
   *
   * @param string $crossingChar
   *
   * @return TableHelper
   */
  public function setCrossingChar($crossingChar) {
    $this->table
      ->getStyle()
      ->setCrossingChar($crossingChar);
    return $this;
  }

  /**
   * Sets header cell format.
   *
   * @param string $cellHeaderFormat
   *
   * @return TableHelper
   */
  public function setCellHeaderFormat($cellHeaderFormat) {
    $this->table
      ->getStyle()
      ->setCellHeaderFormat($cellHeaderFormat);
    return $this;
  }

  /**
   * Sets row cell format.
   *
   * @param string $cellRowFormat
   *
   * @return TableHelper
   */
  public function setCellRowFormat($cellRowFormat) {
    $this->table
      ->getStyle()
      ->setCellHeaderFormat($cellRowFormat);
    return $this;
  }

  /**
   * Sets row cell content format.
   *
   * @param string $cellRowContentFormat
   *
   * @return TableHelper
   */
  public function setCellRowContentFormat($cellRowContentFormat) {
    $this->table
      ->getStyle()
      ->setCellRowContentFormat($cellRowContentFormat);
    return $this;
  }

  /**
   * Sets table border format.
   *
   * @param string $borderFormat
   *
   * @return TableHelper
   */
  public function setBorderFormat($borderFormat) {
    $this->table
      ->getStyle()
      ->setBorderFormat($borderFormat);
    return $this;
  }

  /**
   * Sets cell padding type.
   *
   * @param int $padType STR_PAD_*
   *
   * @return TableHelper
   */
  public function setPadType($padType) {
    $this->table
      ->getStyle()
      ->setPadType($padType);
    return $this;
  }

  /**
   * Renders table to output.
   *
   * Example:
   * +---------------+-----------------------+------------------+
   * | ISBN          | Title                 | Author           |
   * +---------------+-----------------------+------------------+
   * | 99921-58-10-7 | Divine Comedy         | Dante Alighieri  |
   * | 9971-5-0210-0 | A Tale of Two Cities  | Charles Dickens  |
   * | 960-425-059-0 | The Lord of the Rings | J. R. R. Tolkien |
   * +---------------+-----------------------+------------------+
   *
   * @param OutputInterface $output
   */
  public function render(OutputInterface $output) {
    $p = new \ReflectionProperty($this->table, 'output');
    $p
      ->setAccessible(true);
    $p
      ->setValue($this->table, $output);
    $this->table
      ->render();
  }

  /**
   * {@inheritdoc}
   */
  public function getName() {
    return 'table';
  }

}

Members

Namesort descending Modifiers Type Description Overrides
Helper::$helperSet protected property
Helper::formatMemory public static function
Helper::formatTime public static function
Helper::getHelperSet public function Gets the helper set associated with this helper. Overrides HelperInterface::getHelperSet
Helper::setHelperSet public function Sets the helper set associated with this helper. Overrides HelperInterface::setHelperSet
Helper::strlen public static function Returns the length of a string, using mb_strwidth if it is available.
Helper::strlenWithoutDecoration public static function
TableHelper::$table private property
TableHelper::addRow public function
TableHelper::addRows public function
TableHelper::getName public function Returns the canonical name of this helper. Overrides HelperInterface::getName
TableHelper::LAYOUT_BORDERLESS constant
TableHelper::LAYOUT_COMPACT constant
TableHelper::LAYOUT_DEFAULT constant
TableHelper::render public function Renders table to output.
TableHelper::setBorderFormat public function Sets table border format.
TableHelper::setCellHeaderFormat public function Sets header cell format.
TableHelper::setCellRowContentFormat public function Sets row cell content format.
TableHelper::setCellRowFormat public function Sets row cell format.
TableHelper::setCrossingChar public function Sets crossing character.
TableHelper::setHeaders public function
TableHelper::setHorizontalBorderChar public function Sets horizontal border character.
TableHelper::setLayout public function Sets table layout type.
TableHelper::setPaddingChar public function Sets padding character, used for cell padding.
TableHelper::setPadType public function Sets cell padding type.
TableHelper::setRow public function
TableHelper::setRows public function
TableHelper::setVerticalBorderChar public function Sets vertical border character.
TableHelper::__construct public function