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

Conversation

jfsimon
Copy link
Contributor

@jfsimon jfsimon commented Mar 22, 2013

This PR removes description generation from Command, Application and InputDefinition classes and delegate it to specialized descriptor classes, making it dead simple to add new output formats.

Maybe this could include other commands, like router:debug or container:debug (see #5740)?

  • Add a DescriptorProvider which uses DescriptorInterface objects to describe things.
  • Add txt descriptors.
  • Add xml descriptors.
  • Add json descriptors.
  • Add md descriptors.
  • Remove obsolete methods.
  • Repair tests.
Q A
Bug fix? no
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets #6339

/**
* Returns given object's representation.
*
* @param mixed $object
Copy link
Member

Choose a reason for hiding this comment

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

it should be @param object if $object can only be an object. And if it can be something else (a scalar or an array), the argument should be renamed)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

changed, thanks

@igorw
Copy link
Contributor

igorw commented Apr 12, 2013

This PR is massive. It should be broken down into smaller commits that can be reviewed more easily. If possible perhaps even into separate smaller PRs that can be applied atomically without breaking stuff.

@jfsimon
Copy link
Contributor Author

jfsimon commented Apr 12, 2013

@igorw I just unsquashed my commits for you.

{
$this
->configure($options)
->add(new Text\ApplicationTextDescriptor())
Copy link
Contributor

Choose a reason for hiding this comment

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

Wouldn't it be a lot simpler if the application text descriptor itself were responsible for rendering its elements? I think it would simplify the design and lead to less implicit dependency on the order of the descriptors.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure to understand, this class just acts as a "descriptor selector".

@igorw
Copy link
Contributor

igorw commented Apr 12, 2013

I'm not sure if introducing the Document is worth the amount of code it introduces. If #6339 can produce the same result with only 342 new LOC, maybe we should aim for something more similar to it.

@jfsimon
Copy link
Contributor Author

jfsimon commented Apr 12, 2013

@igorw do you think the markdown formatter is overkill?
(I guess the generated documents will change in the future and become more complex).

@igorw
Copy link
Contributor

igorw commented Apr 12, 2013

Possibly. I guess re-implementing pandoc inside of symfony seems like a bit much.

*
* @return string A string representing the InputDefinition
*/
public function asText()
Copy link
Member

Choose a reason for hiding this comment

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

Removing the public method is a BC break. you should provide a BC layer

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I guess asXml() methods should be present too and must be tagged as @deprecated.

Copy link
Member

Choose a reason for hiding this comment

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

right

@jfsimon
Copy link
Contributor Author

jfsimon commented Apr 13, 2013

@igorw I think your right, I'll simplify the markdown descriptor.


// reads native definition
$method = new \ReflectionMethod($this->command, 'getNativeDefinition');
$method->setAccessible(true);
Copy link
Member

Choose a reason for hiding this comment

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

Relying on reflection to get the definition looks like a hack

@stof
Copy link
Member

stof commented Apr 14, 2013

I don't like the hard coupling of descriptors, where each descriptor creates new instances of other descriptors. I leads to several issues:

  • this spawned descriptors don't respect the options set in the DescriptorSelector
  • replacing one of the descriptors in the DescriptorSelector would not be taken into account for nested descriptions.

You should retrieve the needed descriptor from the selector IMO

@jfsimon
Copy link
Contributor Author

jfsimon commented Apr 14, 2013

@stof @igorw could you please take a look at the last commit, I'm not sure to do it the best way.
Actually, I begin to doubt of the entire feature design.

@fabpot
Copy link
Member

fabpot commented Apr 20, 2013

#5740 should indeed use this framework. @jfsimon Can you update this PR accordingly?

@jfsimon
Copy link
Contributor Author

jfsimon commented Apr 20, 2013

@fabpot absolutely. Should I do the same with RouterDebugCommand? Shouldn't this be done in separate PRs?

@fabpot
Copy link
Member

fabpot commented Apr 20, 2013

Let's do that in the same PR (and indeed the router debug command should also be updated).

@fabpot
Copy link
Member

fabpot commented Apr 23, 2013

Can you also removed the *~ files that were committed by mistake?

{
/**
* @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.

Can you remove the blank lines between @param lines?

@fabpot fabpot closed this in 61c56fc Apr 23, 2013
fabpot added a commit that referenced this pull request Oct 1, 2013
…fsimon)

This PR was squashed before being merged into the master branch (closes #7887).

Discussion
----------

[FrameworkBundle] adds routing/container descriptors

The goal of this PR is to add descriptors (as in #7454) for routing and container. This will permit add a `--format` option to `router:debug` and `container:debug` commands (with `txt`, `json`, `xml` and `md` formats).

Commits
-------

22f9bc8 [FrameworkBundle] adds routing/container descriptors
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants