Verzeichnisstruktur phpBB-3.1.0
- Veröffentlicht
- 27.10.2014
So funktioniert es
|
Auf das letzte Element klicken. Dies geht jeweils ein Schritt zurück |
Auf das Icon klicken, dies öffnet das Verzeichnis. Nochmal klicken schließt das Verzeichnis. |
|
(Beispiel Datei-Icons)
|
Auf das Icon klicken um den Quellcode anzuzeigen |
JsonDescriptor.php
001 <?php
002
003 /*
004 * This file is part of the Symfony package.
005 *
006 * (c) Fabien Potencier <fabien@symfony.com>
007 *
008 * For the full copyright and license information, please view the LICENSE
009 * file that was distributed with this source code.
010 */
011
012 namespace Symfony\Component\Console\Descriptor;
013
014 use Symfony\Component\Console\Application;
015 use Symfony\Component\Console\Command\Command;
016 use Symfony\Component\Console\Input\InputArgument;
017 use Symfony\Component\Console\Input\InputDefinition;
018 use Symfony\Component\Console\Input\InputOption;
019
020 /**
021 * JSON descriptor.
022 *
023 * @author Jean-François Simon <contact@jfsimon.fr>
024 */
025 class JsonDescriptor extends Descriptor
026 {
027 /**
028 * {@inheritdoc}
029 */
030 protected function describeInputArgument(InputArgument $argument, array $options = array())
031 {
032 return $this->output(array(
033 'name' => $argument->getName(),
034 'is_required' => $argument->isRequired(),
035 'is_array' => $argument->isArray(),
036 'description' => $argument->getDescription(),
037 'default' => $argument->getDefault(),
038 ), $options);
039 }
040
041 /**
042 * {@inheritdoc}
043 */
044 protected function describeInputOption(InputOption $option, array $options = array())
045 {
046 return $this->output(array(
047 'name' => '--'.$option->getName(),
048 'shortcut' => $option->getShortcut() ? '-'.implode('|-', explode('|', $option->getShortcut())) : '',
049 'accept_value' => $option->acceptValue(),
050 'is_value_required' => $option->isValueRequired(),
051 'is_multiple' => $option->isArray(),
052 'description' => $option->getDescription(),
053 'default' => $option->getDefault(),
054 ), $options);
055 }
056
057 /**
058 * {@inheritdoc}
059 */
060 protected function describeInputDefinition(InputDefinition $definition, array $options = array())
061 {
062 $inputArguments = array();
063 foreach ($definition->getArguments() as $name => $argument) {
064 $inputArguments[$name] = $this->describeInputArgument($argument, array('as_array' => true));
065 }
066
067 $inputOptions = array();
068 foreach ($definition->getOptions() as $name => $option) {
069 $inputOptions[$name] = $this->describeInputOption($option, array('as_array' => true));
070 }
071
072 return $this->output(array('arguments' => $inputArguments, 'options' => $inputOptions), $options);
073 }
074
075 /**
076 * {@inheritdoc}
077 */
078 protected function describeCommand(Command $command, array $options = array())
079 {
080 $command->getSynopsis();
081 $command->mergeApplicationDefinition(false);
082
083 return $this->output(array(
084 'name' => $command->getName(),
085 'usage' => $command->getSynopsis(),
086 'description' => $command->getDescription(),
087 'help' => $command->getProcessedHelp(),
088 'aliases' => $command->getAliases(),
089 'definition' => $this->describeInputDefinition($command->getNativeDefinition(), array('as_array' => true)),
090 ), $options);
091 }
092
093 /**
094 * {@inheritdoc}
095 */
096 protected function describeApplication(Application $application, array $options = array())
097 {
098 $describedNamespace = isset($options['namespace']) ? $options['namespace'] : null;
099 $description = new ApplicationDescription($application, $describedNamespace);
100 $commands = array();
101
102 foreach ($description->getCommands() as $command) {
103 $commands[] = $this->describeCommand($command, array('as_array' => true));
104 }
105
106 $data = $describedNamespace
107 ? array('commands' => $commands, 'namespace' => $describedNamespace)
108 : array('commands' => $commands, 'namespaces' => array_values($description->getNamespaces()));
109
110 return $this->output($data, $options);
111 }
112
113 /**
114 * Outputs data as array or string according to options.
115 *
116 * @param array $data
117 * @param array $options
118 *
119 * @return array|string
120 */
121 private function output(array $data, array $options)
122 {
123 if (isset($options['as_array']) && $options['as_array']) {
124 return $data;
125 }
126
127 return json_encode($data, isset($options['json_encoding']) ? $options['json_encoding'] : 0);
128 }
129 }
130