8000 [Console] application/command as text/xml/whatever decoupling by jfsimon · Pull Request #7454 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[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

Closed
wants to merge 24 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
da67c12
[Console] added descriptor & refactored description commands
jfsimon Mar 22, 2013
f239b1c
[Console] added JSON descriptors
jfsimon Apr 1, 2013
bebf1eb
[Console] added markdown descriptors
jfsimon Apr 3, 2013
43b5e5c
[Console] added forgotten headers
jfsimon Apr 3, 2013
acc7414
[Console] removed unused methods (tests broken)
jfsimon Apr 3, 2013
774794c
[Console] fixed tests
jfsimon Apr 3, 2013
2066a9b
[Console] added XML descriptors
jfsimon Apr 6, 2013
47fa194
[Console] started text derciptors
jfsimon Apr 6, 2013
8b56eb1
[Console] finished text descriptors
jfsimon Apr 8, 2013
27aa872
[Console] repaired tests
jfsimon Apr 10, 2013
30d8807
[Console] re-introduced asText & asXml methods to avoid BC break
jfsimon Apr 14, 2013
9964838
[Console] added command definition merge be fore description
jfsimon Apr 14, 2013
ef6d8ba
[Console] simplified description commands
jfsimon Apr 14, 2013
389101a
[Console] re-introduced --xml option to avoid BC break
jfsimon Apr 14, 2013
84be8de
[Console] simplified mardown descriptors
jfsimon Apr 14, 2013
ce5c0fd
[Console] applied comments from github
jfsimon Apr 14, 2013
49a4612
[Console] applied comments from github
jfsimon Apr 14, 2013
20c10a5
[Console] added provider injection to descriptors
jfsimon Apr 14, 2013
9c7b358
[Console] simplified descriptors
jfsimon Apr 23, 2013
d3ec073
[Console] applied advices from github comments
jfsimon Apr 23, 2013
d70e086
[Console] removed proxy
jfsimon Apr 23, 2013
ce60fb7
[Console] simplified descriptor interface
jfsimon Apr 23, 2013
28f082e
[Console] removed changes
jfsimon Apr 23, 2013
cbb8105
[Console] moved commands arguments
jfsimon Apr 23, 2013
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
[Console] simplified descriptors
  • Loading branch information
jfsimon committed Apr 23, 2013
commit 9c7b3586b5f57aad264e27ac94dae25af07698ce
19 changes: 6 additions & 13 deletions src/Symfony/Component/Console/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@

namespace Symfony\Component\Console;

use Symfony\Component\Console\Descriptor\DescriptorProvider;
use Symfony\Component\Console\Descriptor\TextDescriptor;
use Symfony\Component\Console\Descriptor\XmlDescriptor;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\ArgvInput;
use Symfony\Component\Console\Input\ArrayInput;
Expand Down Expand Up @@ -693,9 +694,9 @@ public static function getAbbreviations($names)
*/
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you need to provide a BC layer to avoid the BC break

public function asText($namespace = null, $raw = false)
{
$descriptor = new DescriptorProvider(array('namespace' => $namespace, 'raw_text' => $raw));
$descriptor = new TextDescriptor();

return $descriptor->get($this, 'txt')->describe($this);
return $descriptor->describeApplication($this, array('namespace' => $namespace, 'raw_text' => $raw));
}

/**
Expand All @@ -710,17 +711,9 @@ public function asText($namespace = null, $raw = false)
*/
public function asXml($namespace = null, $asDom = false)
{
$provider = new DescriptorProvider(array('namespace' => $namespace));
$descriptor = $provider->get($this, 'xml');
$descriptor = new XmlDescriptor();

if ($asDom) {
$dom = new \DOMDocument('1.0', 'UTF-8');
$descriptor->buildDocument($dom, $this);

return $dom;
}

return $descriptor->describe($this);
return $descriptor->describeApplication($this, array('namespace' => $namespace, 'as_dom' => $asDom));
}

/**
Expand Down
19 changes: 6 additions & 13 deletions src/Symfony/Component/Console/Command/Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@

namespace Symfony\Component\Console\Command;

use Symfony\Component\Console\Descriptor\DescriptorProvider;
use Symfony\Component\Console\Descriptor\TextDescriptor;
use Symfony\Component\Console\Descriptor\XmlDescriptor;
use Symfony\Component\Console\Input\InputDefinition;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputArgument;
Expand Down Expand Up @@ -565,9 +566,9 @@ public function getHelper($name)
*/
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This also requires a BC layer

public function asText()
{
$descriptor = new DescriptorProvider();
$descriptor = new TextDescriptor();

return $descriptor->get($this, 'txt')->describe($this);
return $descriptor->describeCommand($this);
}

/**
Expand All @@ -581,17 +582,9 @@ public function asText()
*/
public function asXml($asDom = false)
{
$provider = new DescriptorProvider();
$descriptor = $provider->get($this, 'xml');
$descriptor = new XmlDescriptor();

if ($asDom) {
$dom = new \DOMDocument('1.0', 'UTF-8');
$descriptor->buildDocument($dom, $this);

return $dom;
}

return $descriptor->describe($this);
return $descriptor->describeCommand($this, array('as_dom' => $asDom));
}

private function validateName($name)
Expand Down
40 changes: 0 additions & 40 deletions src/Symfony/Component/Console/Descriptor/AbstractDescriptor.php

This file was deleted.

64 changes: 31 additions & 33 deletions src/Symfony/Component/Console/Descriptor/DescriptorInterface.php
Original file line number Diff line number Diff line change
@@ -1,64 +1,62 @@
<?php

/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Symfony\Component\Console\Descriptor;

use Symfony\Component\Console\Application;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputDefinition;
use Symfony\Component\Console\Input\InputOption;

/**
* @author Jean-François Simon <jeanfrancois.simon@sensiolabs.com>
* Descriptor interface.
*
* @author Jean-François Simon <contact@jfsimon.fr>
*/
interface DescriptorInterface
{
/**
* Configures descriptor with description options.
* @param InputArgument $argument
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As this is the interface, you must add some description of the methods.

*
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you remove the blank lines between @param lines?

* @param array $options Description options
* @param array $options
*
* @return DescriptorInterface
* @return string|mixed
*/
public function configure(array $options);
public function describeInputArgument(InputArgument $argument, array $options = array());

/**
* Returns given object's representation.
* @param InputOption $option
*
* @param object $object The object to describe
* @param array $options
*
* @return string The object formatted description
* @return string|mixed
*/
public function describe($object);
public function describeInputOption(InputOption $option, array $options = array());

/**
* Tests if this descriptor supports given object.
* @param InputDefinition $definition
*
* @param object $object The object to describe
* @param array $options
*
* @return boolean
* @return string|mixed
*/
public function supports($object);
public function describeInputDefinition(InputDefinition $definition, array $options = array());

/**
* Returns descriptor's format name.
* @param Command $command
*
* @return string The format name
*/
public function getFormat();

/**
* Returns true if output formatting is used.
* @param array $options
*
* @return boolean
* @return string|mixed
*/
public function useFormatting();
public function describeCommand(Command $command, array $options = array());

/**
* @param DescriptorProvider $descriptorProvider
* @param Application $application
*
* @param array $options
*
* @return string|mixed
*/
public function setDescriptorProvider(DescriptorProvider $descriptorProvider);
public function describeApplication(Application $application, array $options = array());
}
150 changes: 0 additions & 150 deletions src/Symfony/Component/Console/Descriptor/DescriptorProvider.php

This file was deleted.

Loading
0