Skip to content

Commit

Permalink
[FrameworkBundle] fixed container:debug and router:debug commands
Browse files Browse the repository at this point in the history
  • Loading branch information
fabpot committed Oct 2, 2013
1 parent 5bd18c0 commit d997dfa
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 13 deletions.
Expand Up @@ -46,7 +46,7 @@ protected function configure()
new InputOption('tags', null, InputOption::VALUE_NONE, 'Displays tagged services for an application'),
new InputOption('parameter', null, InputOption::VALUE_REQUIRED, 'Displays a specific parameter for an application'),
new InputOption('parameters', null, InputOption::VALUE_NONE, 'Displays parameters for an application'),
new InputOption('format', null, InputOption::VALUE_REQUIRED, 'To output description in other formats'),
new InputOption('format', null, InputOption::VALUE_REQUIRED, 'To output description in other formats', 'txt'),
new InputOption('raw', null, InputOption::VALUE_NONE, 'To output raw description'),
))
->setDescription('Displays current services for an application')
Expand Down Expand Up @@ -114,7 +114,9 @@ protected function execute(InputInterface $input, OutputInterface $output)
}

$helper = new DescriptorHelper();
$helper->describe($output, $object, $input->getOption('format'), $input->getOption('raw'), $options);
$options['format'] = $input->getOption('format');
$options['raw_text'] = $input->getOption('raw');
$helper->describe($output, $object, $options);
}

/**
Expand Down
Expand Up @@ -52,7 +52,7 @@ protected function configure()
->setDefinition(array(
new InputArgument('name', InputArgument::OPTIONAL, 'A route name'),
new InputOption('show-controllers', null, InputOption::VALUE_NONE, 'Show assigned controllers in overview'),
new InputOption('format', null, InputOption::VALUE_REQUIRED, 'To output route(s) in other formats'),
new InputOption('format', null, InputOption::VALUE_REQUIRED, 'To output route(s) in other formats', 'txt'),
new InputOption('raw', null, InputOption::VALUE_NONE, 'To output raw route(s)'),
))
->setDescription('Displays current routes for an application')
Expand Down Expand Up @@ -80,7 +80,11 @@ protected function execute(InputInterface $input, OutputInterface $output)
if (!$route) {
throw new \InvalidArgumentException(sprintf('The route "%s" does not exist.', $name));
}
$helper->describe($output, $route, $input->getOption('format'), $input->getOption('raw'), array('name' => $name));
$helper->describe($output, $route, array(
'format' => $input->getOption('format'),
'raw_text' => $input->getOption('raw'),
'name' => $name,
));
} else {
$routes = $this->getContainer()->get('router')->getRouteCollection();
$helper->describe($output, $routes, array(
Expand Down
Expand Up @@ -28,6 +28,7 @@ protected function describeRouteCollection(RouteCollection $routes, array $optio
}
$this->describeRoute($route, array('name' => $name));
}
$this->write("\n");
}

/**
Expand All @@ -49,8 +50,9 @@ protected function describeRoute(Route $route, array $options = array())
."\n".'- Path-Regex: '.$route->compile()->getRegex();

$this->write(isset($options['name'])
? $options['name']."\n".str_repeat('-', strlen($options['name']))."\n".$output
? $options['name']."\n".str_repeat('-', strlen($options['name']))."\n\n".$output
: $output);
$this->write("\n");
}

/**
Expand Down Expand Up @@ -133,17 +135,17 @@ protected function describeContainerServices(ContainerBuilder $builder, array $o
}

if (!empty($services['definitions'])) {
$this->write("\n\nDefinitions\n-----------");
$this->write("\n\nDefinitions\n-----------\n");
foreach ($services['definitions'] as $id => $service) {
$this->write("\n\n");
$this->write("\n");
$this->describeContainerDefinition($service, array('id' => $id));
}
}

if (!empty($services['aliases'])) {
$this->write("\n\nAliases\n-------");
$this->write("\n\nAliases\n-------\n");
foreach ($services['aliases'] as $id => $service) {
$this->write("\n\n");
$this->write("\n");
$this->describeContainerAlias($service, array('id' => $id));
}
}
Expand Down Expand Up @@ -182,7 +184,7 @@ protected function describeContainerDefinition(Definition $definition, array $op
}
}

$this->write(isset($options['id']) ? sprintf("**`%s`:**\n%s", $options['id'], $output) : $output);
$this->write(isset($options['id']) ? sprintf("%s\n%s\n\n%s\n", $options['id'], str_repeat('~', strlen($options['id'])), $output) : $output);
}

/**
Expand All @@ -193,7 +195,7 @@ protected function describeContainerAlias(Alias $alias, array $options = array()
$output = '- Service: `'.$alias.'`'
."\n".'- Public: '.($alias->isPublic() ? 'yes' : 'no');

$this->write(isset($options['id']) ? sprintf("**`%s`:**\n%s", $options['id'], $output) : $output);
$this->write(isset($options['id']) ? sprintf("%s\n%s\n\n%s\n", $options['id'], str_repeat('~', strlen($options['id'])), $output) : $output);
}

private function formatRouterConfig(array $array)
Expand Down
Expand Up @@ -84,7 +84,7 @@ protected function describeRoute(Route $route, array $options = array())
$description[] = '<comment>Host-Regex</comment> '.$route->compile()->getHostRegex();
}

$this->writeText(implode("\n", $description), $options);
$this->writeText(implode("\n", $description)."\n", $options);
}

/**
Expand Down Expand Up @@ -256,7 +256,7 @@ protected function describeContainerDefinition(Definition $definition, array $op
$description[] = sprintf('<comment>Synthetic</comment> %s', $definition->isSynthetic() ? 'yes' : 'no');
$description[] = sprintf('<comment>Required File</comment> %s', $definition->getFile() ? $definition->getFile() : '-');

$this->writeText(implode("\n", $description), $options);
$this->writeText(implode("\n", $description)."\n", $options);
}

/**
Expand Down

0 comments on commit d997dfa

Please sign in to comment.