From d229ce584f5a0faa9df01ef19c450a266ecc2430 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Wed, 10 Mar 2010 17:01:50 +0100 Subject: [PATCH] [Console] added __get() to Command to have shorter and more readable code in commands --- src/Symfony/Components/Console/Command/Command.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/Symfony/Components/Console/Command/Command.php b/src/Symfony/Components/Console/Command/Command.php index db259d330c..bbde5f94e0 100644 --- a/src/Symfony/Components/Console/Command/Command.php +++ b/src/Symfony/Components/Console/Command/Command.php @@ -423,6 +423,20 @@ class Command return $this->application->getHelperSet()->get($name); } + /** + * Gets a helper instance by name. + * + * @param string $name The helper name + * + * @return mixed The helper value + * + * @throws \InvalidArgumentException if the helper is not defined + */ + public function __get($name) + { + return $this->application->getHelperSet()->get($name); + } + /** * Returns a text representation of the command. *