Symfony\Component\Console\Command\Command::getHelper PHP Method

getHelper() public method

Gets a helper instance by name.
public getHelper ( string $name ) : mixed
$name string The helper name
return mixed The helper value
    public function getHelper($name)
    {
        if (null === $this->helperSet) {
            throw new LogicException(sprintf('Cannot retrieve helper "%s" because there is no HelperSet defined. Did you forget to add your command to the application or to set the application on the command using the setApplication() method? You can also set the HelperSet directly using the setHelperSet() method.', $name));
        }
        return $this->helperSet->get($name);
    }

Usage Example

 /** @test */
 public function it_opens_a_dialog_to_select_the_entity_and_count_if_no_entity_given()
 {
     /** @var SymfonyQuestionHelper $question */
     $question = $this->command->getHelper('question');
     $question->setInputStream($this->getInputStream("1\n5\n"));
     $this->commandTester->execute(['command' => $this->command->getName()]);
     $count = $this->getDatabaseCount(App::class, []);
     $this->assertEquals(5, $count);
     $this->assertContains(sprintf('%s seeded.', App::class), $this->commandTester->getDisplay());
 }
All Usage Examples Of Symfony\Component\Console\Command\Command::getHelper