Webmozart\Console\UI\Component\Table::render PHP Метод

render() публичный Метод

Renders the table.
public render ( IO $io, integer $indentation )
$io Webmozart\Console\Api\IO\IO The I/O.
$indentation integer The number of spaces to indent.
    public function render(IO $io, $indentation = 0)
    {
        // Is the table empty?
        if (!$this->rows) {
            return;
        }
        $screenWidth = $io->getTerminalDimensions()->getWidth();
        $excessColumnWidth = max(StringUtil::getLength(sprintf($this->style->getHeaderCellFormat(), ''), $io), StringUtil::getLength(sprintf($this->style->getCellFormat(), ''), $io));
        $wrapper = $this->getCellWrapper($io, $screenWidth, $excessColumnWidth, $indentation);
        $this->renderRows($io, $wrapper->getWrappedRows(), $wrapper->getColumnLengths(), $excessColumnWidth, $indentation);
    }

Usage Example

Пример #1
0
 public function handleList(Args $args, IO $io)
 {
     $table = new Table(PuliTableStyle::borderless());
     $table->setHeaderRow(array('Name', 'Class', 'Description'));
     foreach ($this->installerManager->getInstallerDescriptors() as $descriptor) {
         $className = $descriptor->getClassName();
         if (!$args->isOptionSet('long')) {
             $className = StringUtil::getShortClassName($className);
         }
         $parameters = array();
         foreach ($descriptor->getParameters() as $parameterName => $parameter) {
             if (!$parameter->isRequired()) {
                 $parameterName .= '=' . StringUtil::formatValue($parameter->getDefaultValue());
             }
             $parameters[] = $parameterName;
         }
         $description = $descriptor->getDescription();
         if (!empty($parameters)) {
             // non-breaking space
             $description .= ' <c1>(' . implode(", ", $parameters) . ')</c1>';
         }
         $table->addRow(array('<u>' . $descriptor->getName() . '</u>', '<c1>' . $className . '</c1>', $description));
     }
     $table->render($io);
     return 0;
 }
All Usage Examples Of Webmozart\Console\UI\Component\Table::render