Skip to content

Commit 0e9ce76

Browse files
committed
Merge branch '2.0' into 2.1
2 parents cd86546 + 88f7b5e commit 0e9ce76

File tree

11 files changed

+394
-12
lines changed

11 files changed

+394
-12
lines changed

components/console/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ Console
66

77
introduction
88
usage
9+
single_command_tool

components/console/introduction.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -401,3 +401,9 @@ returns the returned code from the command (return value from command's
401401
something and display feedback to the user. So, instead of calling a
402402
command from the Web, refactor your code and move the logic to a new
403403
class.
404+
405+
Learn More!
406+
-----------
407+
408+
* :doc:`/components/console/usage`
409+
* :doc:`/components/console/single_command_tool`
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
.. index::
2+
single: Console; Single command application
3+
4+
How to build an Application that is a single Command
5+
====================================================
6+
7+
When building a command line tool, you may not need to provide several commands.
8+
In such case, having to pass the command name each time is tedious. Fortunately,
9+
it is possible to remove this need by extending the application::
10+
11+
namespace Acme\Tool;
12+
13+
use Symfony\Component\Console\Application;
14+
use Symfony\Component\Console\Input\InputInterface;
15+
16+
class MyApplication extends Application
17+
{
18+
/**
19+
* Gets the name of the command based on input.
20+
*
21+
* @param InputInterface $input The input interface
22+
*
23+
* @return string The command name
24+
*/
25+
protected function getCommandName(InputInterface $input)
26+
{
27+
// This should return the name of your command.
28+
return 'my_command';
29+
}
30+
31+
/**
32+
* Gets the default commands that should always be available.
33+
*
34+
* @return array An array of default Command instances
35+
*/
36+
protected function getDefaultCommands()
37+
{
38+
// Keep the core default commands to have the HelpCommand
39+
// which is used when using the --help option
40+
$defaultCommands = parent::getDefaultCommands()
41+
42+
$defaultCommands[] = new MyCommand();
43+
44+
return $defaultCommands;
45+
}
46+
}
47+
48+
When calling your console script, the command `MyCommand` will then always
49+
be used, without having to pass its name.

components/console/usage.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
.. index::
22
single: Console; Usage
33

4-
Console Usage
5-
=============
4+
Using Console Commands, Shortcuts and Built-in Commands
5+
=======================================================
66

77
In addition to the options you specify for your commands, there are some
88
built-in options as well as a couple of built-in commands for the console component.

components/dom_crawler.rst

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -192,17 +192,16 @@ instance with just the selected link(s). Calling ``link()`` gives us a special
192192
The :class:`Symfony\\Component\\DomCrawler\\Link` object has several useful
193193
methods to get more information about the selected link itself::
194194

195-
// return the raw href value
196-
$href = $link->getRawUri();
197-
198195
// return the proper URI that can be used to make another request
199196
$uri = $link->getUri();
200197

201-
The ``getUri()`` is especially useful as it cleans the ``href`` value and
202-
transforms it into how it should really be processed. For example, for a
203-
link with ``href="#foo"``, this would return the full URI of the current
204-
page suffixed with ``#foo``. The return from ``getUri()`` is always a full
205-
URI that you can act on.
198+
.. note::
199+
200+
The ``getUri()`` is especially useful as it cleans the ``href`` value and
201+
transforms it into how it should really be processed. For example, for a
202+
link with ``href="#foo"``, this would return the full URI of the current
203+
page suffixed with ``#foo``. The return from ``getUri()`` is always a full
204+
URI that you can act on.
206205

207206
Forms
208207
.....

components/map.rst.inc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
* :doc:`/components/console/introduction`
1515
* :doc:`/components/console/usage`
16+
* :doc:`/components/console/single_command_tool`
1617

1718
* **CSS Selector**
1819

components/templating.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ sub-template to set its parent template.
8787
To use template inheritance, the :class:`Symfony\\Component\\Templating\\Helper\\SlotsHelper`
8888
helper must be registered::
8989

90-
use Symfony\Templating\Helper\SlotsHelper;
90+
use Symfony\Component\Templating\Helper\SlotsHelper;
9191

9292
$view->set(new SlotsHelper());
9393

cookbook/assetic/asset_management.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ directly:
2424
<script src="<?php echo $view['assets']->getUrl('js/script.js') ?>" type="text/javascript" />
2525
2626
But *with* Assetic, you can manipulate these assets however you want (or
27-
load them from anywhere) before serving them. These means you can:
27+
load them from anywhere) before serving them. This means you can:
2828
2929
* Minify and combine all of your CSS and JS files
3030

0 commit comments

Comments
 (0)