Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[FrameworkBundle] use Table instead of the deprecated TableHelper #12970

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

Merged
merged 1 commit into from
Jan 5, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
7 changes: 7 additions & 0 deletions UPGRADE-2.5.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
UPGRADE FROM 2.4 to 2.5
=======================

FrameworkBundle
---------------

* The `Symfony\Bundle\FrameworkBundle\Console\Descriptor\Descriptor::renderTable()`
method expects the table to be an instance of `Symfony\Component\Console\Helper\Table`
instead of `Symfony\Component\Console\Helper\TableHelper`.

Routing
-------

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
namespace Symfony\Bundle\FrameworkBundle\Console\Descriptor;

use Symfony\Component\Console\Descriptor\DescriptorInterface;
use Symfony\Component\Console\Helper\TableHelper;
use Symfony\Component\Console\Helper\Table;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\DependencyInjection\Alias;
use Symfony\Component\DependencyInjection\ContainerBuilder;
Expand Down Expand Up @@ -71,6 +71,16 @@ public function describe(OutputInterface $output, $object, array $options = arra
}
}

/**
* Returns the output.
*
* @return OutputInterface The output
*/
protected function getOutput()
Copy link
Contributor

Choose a reason for hiding this comment

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

I think that changing the visibility of $output is enough.

Copy link
Member Author

Choose a reason for hiding this comment

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

Changing the visibility makes it mutable. The methods allows us to keep the property read-only.

{
return $this->output;
}

/**
* Writes content to output.
*
Expand All @@ -85,17 +95,18 @@ protected function write($content, $decorated = false)
/**
* Writes content to output.
*
* @param TableHelper $table
* @param bool $decorated
* @param Table $table
* @param bool $decorated
*/
protected function renderTable(TableHelper $table, $decorated = false)
protected function renderTable(Table $table, $decorated = false)
{
if (!$decorated) {
$table->setCellRowFormat('%s');
$table->setCellHeaderFormat('%s');
$table->getStyle()->setCellRowFormat('%s');
$table->getStyle()->setCellRowContentFormat('%s');
$table->getStyle()->setCellHeaderFormat('%s');
}

$table->render($this->output);
$table->render();
Copy link
Contributor

Choose a reason for hiding this comment

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

IMO the render method should also allow to pass the output as parameter (as it has been in TableHelper). It makes way more sense and then we don't need the protected getOutput method at all.

Copy link
Contributor

Choose a reason for hiding this comment

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

The current way of passing the output as constructor to the Table object makes not much sense. The table object is just a representation of a table. And a table is not bound to the ouput, just the rendering is.

Copy link
Member Author

Choose a reason for hiding this comment

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

I see your point. But shouldn't we move this discussion into a new issue?

}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

namespace Symfony\Bundle\FrameworkBundle\Console\Descriptor;

use Symfony\Component\Console\Helper\TableHelper;
use Symfony\Component\Console\Helper\Table;
use Symfony\Component\DependencyInjection\Alias;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Definition;
Expand All @@ -31,8 +31,8 @@ protected function describeRouteCollection(RouteCollection $routes, array $optio
{
$showControllers = isset($options['show_controllers']) && $options['show_controllers'];
$headers = array('Name', 'Method', 'Scheme', 'Host', 'Path');
$table = new TableHelper();
$table->setLayout(TableHelper::LAYOUT_COMPACT);
$table = new Table($this->getOutput());
$table->setStyle('compact');
$table->setHeaders($showControllers ? array_merge($headers, array('Controller')) : $headers);

foreach ($routes->all() as $name => $route) {
Expand Down Expand Up @@ -99,8 +99,8 @@ protected function describeRoute(Route $route, array $options = array())
*/
protected function describeContainerParameters(ParameterBag $parameters, array $options = array())
{
$table = new TableHelper();
$table->setLayout(TableHelper::LAYOUT_COMPACT);
$table = new Table($this->getOutput());
$table->setStyle('compact');
$table->setHeaders(array('Parameter', 'Value'));

foreach ($this->sortParameters($parameters) as $parameter => $value) {
Expand Down Expand Up @@ -200,8 +200,8 @@ protected function describeContainerServices(ContainerBuilder $builder, array $o
$tagsCount = count($maxTags);
$tagsNames = array_keys($maxTags);

$table = new TableHelper();
$table->setLayout(TableHelper::LAYOUT_COMPACT);
$table = new Table($this->getOutput());
$table->setStyle('compact');
$table->setHeaders(array_merge(array('Service ID'), $tagsNames, array('Scope', 'Class name')));

foreach ($this->sortServiceIds($serviceIds) as $serviceId) {
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Bundle/FrameworkBundle/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
},
"require-dev": {
"symfony/browser-kit": "~2.4",
"symfony/console": "~2.4,>=2.4.8",
"symfony/console": "~2.5,>=2.5.2",
"symfony/css-selector": "~2.0,>=2.0.5",
"symfony/dom-crawler": "~2.0,>=2.0.5",
"symfony/finder": "~2.0,>=2.0.5",
Expand Down