master

laravel/framework

Last updated at: 29/12/2023 09:21

TwoColumnDetail.php

TLDR

This file implements the TwoColumnDetail class in the Illuminate\Console\View\Components namespace. The class has a single method called render which renders a view with two columns of content.

Methods

render($first, $second = null, $verbosity = OutputInterface::VERBOSITY_NORMAL)

This method renders the TwoColumnDetail component using the given arguments. It takes three parameters:

  • $first (string): The content for the first column.
  • $second (string|null): The content for the second column. It is optional and defaults to null.
  • $verbosity (int): The verbosity level for the render. It is optional and defaults to OutputInterface::VERBOSITY_NORMAL.

The method performs the following steps:

  1. Calls the mutate method on the $first content using an array of mutator classes.
  2. Calls the mutate method on the $second content using an array of mutator classes.
  3. Renders the view called 'two-column-detail' with the $first and $second contents.
<?php

namespace Illuminate\Console\View\Components;

use Symfony\Component\Console\Output\OutputInterface;

class TwoColumnDetail extends Component
{
    /**
     * Renders the component using the given arguments.
     *
     * @param  string  $first
     * @param  string|null  $second
     * @param  int  $verbosity
     * @return void
     */
    public function render($first, $second = null, $verbosity = OutputInterface::VERBOSITY_NORMAL)
    {
        $first = $this->mutate($first, [
            Mutators\EnsureDynamicContentIsHighlighted::class,
            Mutators\EnsureNoPunctuation::class,
            Mutators\EnsureRelativePaths::class,
        ]);

        $second = $this->mutate($second, [
            Mutators\EnsureDynamicContentIsHighlighted::class,
            Mutators\EnsureNoPunctuation::class,
            Mutators\EnsureRelativePaths::class,
        ]);

        $this->renderView('two-column-detail', [
            'first' => $first,
            'second' => $second,
        ], $verbosity);
    }
}