-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
[Console] application/command as text/xml/whatever decoupling #7454
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
da67c12
f239b1c
bebf1eb
43b5e5c
acc7414
774794c
2066a9b
47fa194
8b56eb1
27aa872
30d8807
9964838
ef6d8ba
389101a
84be8de
ce5c0fd
49a4612
20c10a5
9c7b358
d3ec073
d70e086
ce60fb7
28f082e
cbb8105
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,6 +29,7 @@ class DescriptorProvider | |
private $options = array( | ||
'default_format' => 'txt', | ||
'namespace' => null, | ||
'raw_text' => false, | ||
'json_encoding' => 0, | ||
'markdown_width' => 120, | ||
); | ||
|
@@ -42,6 +43,11 @@ public function __construct(array $options = array()) | |
{ | ||
$this | ||
->configure($options) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You are configuring, then adding the descriptors. This means the configuration will not be applied to them at all. Is that intentional? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, I see. Missed that part. :) |
||
->add(new Xml\ApplicationXmlDescriptor()) | ||
->add(new Xml\CommandXmlDescriptor()) | ||
->add(new Xml\InputDefinitionXmlDescriptor()) | ||
->add(new Xml\InputArgumentXmlDescriptor()) | ||
->add(new Xml\InputOptionXmlDescriptor()) | ||
->add(new Json\ApplicationJsonDescriptor()) | ||
->add(new Json\CommandJsonDescriptor()) | ||
->add(new Json\InputDefinitionJsonDescriptor()) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,7 +23,7 @@ class CommandJsonDescriptor extends AbstractJsonDescriptor | |
*/ | ||
public function getData($object) | ||
{ | ||
$definitionDescriptor = $this->build(new InputDefinitionJsonDescriptor()); | ||
$definitionDescriptor = new InputDefinitionJsonDescriptor(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. creating a new descriptor inside the descriptor looks weird to me |
||
|
||
/** @var Command $object */ | ||
return array( | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Symfony package. | ||
* | ||
* (c) Fabien Potencier <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Symfony\Component\Console\Descriptor\Text; | ||
|
||
use Symfony\Component\Console\Descriptor\DescriptorInterface; | ||
|
||
/** | ||
* @author Jean-François Simon <[email protected]> | ||
*/ | ||
abstract class AbstractTextDescriptor implements DescriptorInterface | ||
{ | ||
/** | ||
* @var boolean | ||
*/ | ||
private $raw; | ||
|
||
/** | ||
* @param boolean $raw | ||
*/ | ||
public function __construct($raw = false) | ||
{ | ||
$this->raw = $raw; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function configure(array $options) | ||
{ | ||
if (isset($options['raw_text'])) { | ||
$this->raw = $options['raw_text']; | ||
} | ||
|
||
return $this; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function describe($object) | ||
{ | ||
return $this->raw ? $this->getRawText($object) : $this->getFormattedText($object); | ||
} | ||
|
||
/** | ||
* Returns object's raw text description. | ||
* | ||
* @param object $object | ||
* | ||
* @return string | ||
*/ | ||
abstract public function getRawText($object); | ||
|
||
/** | ||
* Returns object's formatted text description. | ||
* | ||
* @param object $object | ||
* | ||
* @return string | ||
*/ | ||
abstract public function getFormattedText($object); | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function getFormat() | ||
{ | ||
return 'txt'; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function useFormatting() | ||
{ | ||
return false; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we have standardize to use
sprintf
for exception messages.