11.. index ::
22 single: Console; Create commands
33
4- How to create a Console Command
5- ===============================
4+ Kako izdelati ukaz za konzolo
5+ =============================
66
7- The Console page of the Components section (:doc: `/components/console/introduction `) covers
8- how to create a Console command. This cookbook article covers the differences
9- when creating Console commands within the Symfony2 framework .
7+ Stran o konzoli sekcije komponent (:doc: `/components/console/introduction `) pokriva
8+ kako izdelati ukaz za konzolo. Ta članek receptov pokriva razlike,
9+ ko izdelujete ukaze za konzolo znotraj Symfony2 ogrodja .
1010
11- Automatically Registering Commands
12- ----------------------------------
11+ Avtomatska registracija ukazov
12+ ------------------------------
1313
14- To make the console commands available automatically with Symfony2, create a
15- ``Command `` directory inside your bundle and create a php file suffixed with
16- ``Command.php `` for each command that you want to provide. For example, if you
17- want to extend the ``AcmeDemoBundle `` (available in the Symfony Standard
18- Edition) to greet you from the command line, create ``GreetCommand.php `` and
19- add the following to it ::
14+ Da naredite konzolne ukaze na voljo avtomatsko v Symfony2, izdelajte
15+ ``Command `` direktorij znotraj vašega paketa in izdelajte php datoteko s predpono
16+ ``Command.php `` za vsak ukaz, ki ga želite ponuditi. Na primer, če želite
17+ razširiti ``AcmeDemoBundle `` (na voljo v Symfony standardni izdaji), da vas
18+ pozdravi iz ukazne vrstice, izdelajte ``GreetCommand.php `` in
19+ dodajte sledeče vanjo ::
2020
2121 // src/Acme/DemoBundle/Command/GreetCommand.php
2222 namespace Acme\DemoBundle\Command;
@@ -56,24 +56,24 @@ add the following to it::
5656 }
5757 }
5858
59- This command will now automatically be available to run :
59+ Ta ukaz bo sedaj avtomatsko na voljo za pogon :
6060
6161.. code-block :: bash
6262
6363 $ app/console demo:greet Fabien
6464
6565 .. _cookbook-console-dic :
6666
67- Register Commands in the Service Container
68- ------------------------------------------
67+ Registracija ukazov v storitvenem kontejnerju
68+ ---------------------------------------------
6969
7070.. versionadded :: 2.4
71- Support for registering commands in the service container was added in
72- version 2.4.
71+ Podpora za registracijo ukazov v storitvenem kontejnerju je bila dodana v
72+ verziji 2.4.
7373
74- Instead of putting your command in the ``Command `` directory and having Symfony
75- auto-discover it for you, you can register commands in the service container
76- using the ``console.command `` tag :
74+ Namesto dodajanja ukaza v direktorij ``Command `` in da jih Symfony
75+ avtomatsko odkriva za vas, lahko registrirate ukaze v storitvenem kontejnerju
76+ z uporabo ``console.command `` značke :
7777
7878.. configuration-block ::
7979
@@ -111,18 +111,18 @@ using the ``console.command`` tag:
111111
112112 .. tip ::
113113
114- Registering your command as a service gives you more control over its
115- location and the services that are injected into it. But, there are no
116- functional advantages, so you don't need to register your command as a service .
114+ Registracija vašega ukaza kot storitve, vam da več kontrole nad njeno
115+ lokacijo in storitvami, ki so injicirani v njih. Vendar ni nikakršnih
116+ funkcionalnostnih prednosti, tako da ne potrebujete registrirati vaših ukazov kot storitev .
117117
118- Getting Services from the Service Container
119- -------------------------------------------
118+ Pridobitev storitev iz storitvenega kontejnerja
119+ -----------------------------------------------
120120
121- By using :class: `Symfony\\ Bundle\\ FrameworkBundle\\ Command\\ ContainerAwareCommand `
122- as the base class for the command (instead of the more basic
123- :class: `Symfony\\ Component\\ Console\\ Command\\ Command `), you have access to the
124- service container. In other words, you have access to any configured service .
125- For example, you could easily extend the task to be translatable ::
121+ Z uporabo :class: `Symfony\\ Bundle\\ FrameworkBundle\\ Command\\ ContainerAwareCommand `
122+ kot osnovnega razreda za ukaz (namesto bolj osnovnega
123+ :class: `Symfony\\ Component\\ Console\\ Command\\ Command `), imate dostop do
124+ storitvenega kontejnerja. Z drugimi besedami imate dostop do kakršnih koli nastavljenih storitev .
125+ Na primer, lahko bi enostavno razširili opravilo, da je prevedljivo ::
126126
127127 protected function execute(InputInterface $input, OutputInterface $output)
128128 {
@@ -135,12 +135,12 @@ For example, you could easily extend the task to be translatable::
135135 }
136136 }
137137
138- Testing Commands
139- ----------------
138+ Testiranje ukazov
139+ -----------------
140140
141- When testing commands used as part of the full framework
142- :class: `Symfony\\ Bundle\\ FrameworkBundle\\ Console\\ Application <Symfony\\ Bundle\\ FrameworkBundle\\ Console\\ Application> ` should be used
143- instead of
141+ Ko testirate ukaze uporabljenih kot del celotnega ogrodja
142+ :class: `Symfony\\ Bundle\\ FrameworkBundle\\ Console\\ Application <Symfony\\ Bundle\\ FrameworkBundle\\ Console\\ Application> ` bi moral biti uporabljen
143+ namesto
144144:class: `Symfony\\ Component\\ Console\\ Application <Symfony\\ Component\\ Console\\ Application> `::
145145
146146 use Symfony\Component\Console\Tester\CommandTester;
@@ -173,12 +173,12 @@ instead of
173173
174174.. note ::
175175
176- In the specific case above, the ``name `` parameter and the ``--yell `` option
177- are not mandatory for the command to work, but are shown so you can see
178- how to customize them when calling the command .
176+ V posebnem primeru zgoraj parameter ``name `` in opcija ``--yell ``
177+ nista obvezna, da ukaz deluje, vendar sta prikazana, da lahko vidite
178+ kako jih prilagoditi, ko kličete ukaz .
179179
180- To be able to use the fully set up service container for your console tests
181- you can extend your test from
180+ Da lahko uporabite celotno nastavljen storitveni kontejner za vaše konzolne teste,
181+ lahko razširite vaš test iz
182182:class: `Symfony\\ Bundle\\ FrameworkBundle\\ Test\\ WebTestCase `::
183183
184184 use Symfony\Component\Console\Tester\CommandTester;
0 commit comments