getName() public method

Gets the name of the application.
public getName ( ) : string
return string The application name
Beispiel #1
1
 /**
  * @param Application $application
  * @param string|null $namespace
  *
  * @return \DOMDocument
  */
 public function getApplicationDocument(Application $application, $namespace = null)
 {
     $dom = new \DOMDocument('1.0', 'UTF-8');
     $dom->appendChild($rootXml = $dom->createElement('symfony'));
     if ($application->getName() !== 'UNKNOWN') {
         $rootXml->setAttribute('name', $application->getName());
         if ($application->getVersion() !== 'UNKNOWN') {
             $rootXml->setAttribute('version', $application->getVersion());
         }
     }
     $rootXml->appendChild($commandsXML = $dom->createElement('commands'));
     $description = new ApplicationDescription($application, $namespace);
     if ($namespace) {
         $commandsXML->setAttribute('namespace', $namespace);
     }
     foreach ($description->getCommands() as $command) {
         $this->appendDocument($commandsXML, $this->getCommandDocument($command));
     }
     if (!$namespace) {
         $rootXml->appendChild($namespacesXML = $dom->createElement('namespaces'));
         foreach ($description->getNamespaces() as $namespaceDescription) {
             $namespacesXML->appendChild($namespaceArrayXML = $dom->createElement('namespace'));
             $namespaceArrayXML->setAttribute('id', $namespaceDescription['id']);
             foreach ($namespaceDescription['commands'] as $name) {
                 $namespaceArrayXML->appendChild($commandXML = $dom->createElement('command'));
                 $commandXML->appendChild($dom->createTextNode($name));
             }
         }
     }
     return $dom;
 }
Beispiel #2
0
 /**
  * Constructor.
  *
  * If there is no readline support for the current PHP executable
  * a \RuntimeException exception is thrown.
  *
  * @param Application $application An application instance
  *
  * @throws \RuntimeException When Readline extension is not enabled
  */
 public function __construct(Application $application)
 {
     $this->hasReadline = function_exists('readline');
     $this->application = $application;
     $this->history = getenv('HOME') . '/.history_' . $application->getName();
     $this->output = new ConsoleOutput();
     $this->prompt = $application->getName() . ' > ';
 }
Beispiel #3
0
 /**
  * Constructor.
  *
  * If there is no readline support for the current PHP executable
  * a \RuntimeException exception is thrown.
  *
  * @param Application $application An application instance
  */
 public function __construct(Application $application)
 {
     @trigger_error('The ' . __CLASS__ . ' class is deprecated since Symfony 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
     $this->hasReadline = function_exists('readline');
     $this->application = $application;
     $this->history = getenv('HOME') . '/.history_' . $application->getName();
     $this->output = new ConsoleOutput();
 }
Beispiel #4
0
 function it_should_wrap_getApplication_in_a_shell(Application $app, HelperSet $helperSet)
 {
     $app->getHelperSet()->willReturn($helperSet);
     $app->getName()->willReturn('test');
     $this->setApplication($app);
     $shell = $this->getShell();
     $shell->shouldHaveType('Symfony\\Component\\Console\\Shell');
 }
Beispiel #5
0
 /**
  * Constructor.
  *
  * If there is no readline support for the current PHP executable
  * a \RuntimeException exception is thrown.
  *
  * @param Application $application An application instance
  *
  * @throws \RuntimeException When Readline extension is not enabled
  */
 public function __construct(Application $application)
 {
     if (!function_exists('readline')) {
         throw new \RuntimeException('Unable to start the shell as the Readline extension is not enabled.');
     }
     $this->application = $application;
     $this->history = getenv('HOME') . '/.history_' . $application->getName();
     $this->output = new ConsoleOutput();
 }
 /**
  * {@inheritdoc}
  */
 protected function describeApplication(Application $application, array $options = array())
 {
     $describedNamespace = isset($options['namespace']) ? $options['namespace'] : null;
     $description = new ApplicationDescription($application, $describedNamespace);
     $blocks = array($application->getName() . "\n" . str_repeat('=', strlen($application->getName())));
     foreach ($description->getNamespaces() as $namespace) {
         if (ApplicationDescription::GLOBAL_NAMESPACE !== $namespace['id']) {
             $blocks[] = '**' . $namespace['id'] . ':**';
         }
         $blocks[] = implode("\n", array_map(function ($commandName) {
             return '* ' . $commandName;
         }, $namespace['commands']));
     }
     foreach ($description->getCommands() as $command) {
         $blocks[] = $this->describeCommand($command);
     }
     return implode("\n\n", $blocks);
 }
Beispiel #7
0
 /**
  * {@inheritdoc}
  */
 protected function describeApplication(Application $application, array $options = array())
 {
     $describedNamespace = isset($options['namespace']) ? $options['namespace'] : null;
     $description = new ApplicationDescription($application, $describedNamespace);
     $commands = array();
     foreach ($description->getCommands() as $command) {
         $commands[] = $this->getCommandData($command);
     }
     $data = array();
     if ('UNKNOWN' !== $application->getName()) {
         $data['application']['name'] = $application->getName();
         if ('UNKNOWN' !== $application->getVersion()) {
             $data['application']['version'] = $application->getVersion();
         }
     }
     $data['commands'] = $commands;
     if ($describedNamespace) {
         $data['namespace'] = $describedNamespace;
     } else {
         $data['namespaces'] = array_values($description->getNamespaces());
     }
     $this->writeData($data, $options);
 }
 public function testSetGetName()
 {
     $application = new Application();
     $application->setName('foo');
     $this->assertEquals('foo', $application->getName(), '->setName() sets the name of the application');
 }