[ Index ] |
PHP Cross Reference of phpBB-3.1.12-deutsch |
[Summary view] [Print] [Text view]
1 <?php 2 3 /* 4 * This file is part of the Symfony package. 5 * 6 * (c) Fabien Potencier <fabien@symfony.com> 7 * 8 * For the full copyright and license information, please view the LICENSE 9 * file that was distributed with this source code. 10 */ 11 12 namespace Symfony\Component\Console\Descriptor; 13 14 use Symfony\Component\Console\Application; 15 use Symfony\Component\Console\Command\Command; 16 use Symfony\Component\Console\Input\InputArgument; 17 use Symfony\Component\Console\Input\InputDefinition; 18 use Symfony\Component\Console\Input\InputOption; 19 20 /** 21 * Markdown descriptor. 22 * 23 * @author Jean-François Simon <contact@jfsimon.fr> 24 */ 25 class MarkdownDescriptor extends Descriptor 26 { 27 /** 28 * {@inheritdoc} 29 */ 30 protected function describeInputArgument(InputArgument $argument, array $options = array()) 31 { 32 return '**'.$argument->getName().':**'."\n\n" 33 .'* Name: '.($argument->getName() ?: '<none>')."\n" 34 .'* Is required: '.($argument->isRequired() ? 'yes' : 'no')."\n" 35 .'* Is array: '.($argument->isArray() ? 'yes' : 'no')."\n" 36 .'* Description: '.($argument->getDescription() ?: '<none>')."\n" 37 .'* Default: `'.str_replace("\n", '', var_export($argument->getDefault(), true)).'`'; 38 } 39 40 /** 41 * {@inheritdoc} 42 */ 43 protected function describeInputOption(InputOption $option, array $options = array()) 44 { 45 return '**'.$option->getName().':**'."\n\n" 46 .'* Name: `--'.$option->getName().'`'."\n" 47 .'* Shortcut: '.($option->getShortcut() ? '`-'.implode('|-', explode('|', $option->getShortcut())).'`' : '<none>')."\n" 48 .'* Accept value: '.($option->acceptValue() ? 'yes' : 'no')."\n" 49 .'* Is value required: '.($option->isValueRequired() ? 'yes' : 'no')."\n" 50 .'* Is multiple: '.($option->isArray() ? 'yes' : 'no')."\n" 51 .'* Description: '.($option->getDescription() ?: '<none>')."\n" 52 .'* Default: `'.str_replace("\n", '', var_export($option->getDefault(), true)).'`'; 53 } 54 55 /** 56 * {@inheritdoc} 57 */ 58 protected function describeInputDefinition(InputDefinition $definition, array $options = array()) 59 { 60 $blocks = array(); 61 62 if (count($definition->getArguments()) > 0) { 63 $blocks[] = '### Arguments:'; 64 foreach ($definition->getArguments() as $argument) { 65 $blocks[] = $this->describeInputArgument($argument); 66 } 67 } 68 69 if (count($definition->getOptions()) > 0) { 70 $blocks[] = '### Options:'; 71 foreach ($definition->getOptions() as $option) { 72 $blocks[] = $this->describeInputOption($option); 73 } 74 } 75 76 return implode("\n\n", $blocks); 77 } 78 79 /** 80 * {@inheritdoc} 81 */ 82 protected function describeCommand(Command $command, array $options = array()) 83 { 84 $command->getSynopsis(); 85 $command->mergeApplicationDefinition(false); 86 87 $markdown = $command->getName()."\n" 88 .str_repeat('-', strlen($command->getName()))."\n\n" 89 .'* Description: '.($command->getDescription() ?: '<none>')."\n" 90 .'* Usage: `'.$command->getSynopsis().'`'."\n" 91 .'* Aliases: '.(count($command->getAliases()) ? '`'.implode('`, `', $command->getAliases()).'`' : '<none>'); 92 93 if ($help = $command->getProcessedHelp()) { 94 $markdown .= "\n\n".$help; 95 } 96 97 if ($definitionMarkdown = $this->describeInputDefinition($command->getNativeDefinition())) { 98 $markdown .= "\n\n".$definitionMarkdown; 99 } 100 101 return $markdown; 102 } 103 104 /** 105 * {@inheritdoc} 106 */ 107 protected function describeApplication(Application $application, array $options = array()) 108 { 109 $describedNamespace = isset($options['namespace']) ? $options['namespace'] : null; 110 $description = new ApplicationDescription($application, $describedNamespace); 111 $blocks = array($application->getName()."\n".str_repeat('=', strlen($application->getName()))); 112 113 foreach ($description->getNamespaces() as $namespace) { 114 if (ApplicationDescription::GLOBAL_NAMESPACE !== $namespace['id']) { 115 $blocks[] = '**'.$namespace['id'].':**'; 116 } 117 118 $blocks[] = implode("\n", array_map(function ($commandName) { 119 return '* '.$commandName; 120 }, $namespace['commands'])); 121 } 122 123 foreach ($description->getCommands() as $command) { 124 $blocks[] = $this->describeCommand($command); 125 } 126 127 return implode("\n\n", $blocks); 128 } 129 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Thu Jan 11 00:25:41 2018 | Cross-referenced by PHPXref 0.7.1 |