1
1
DoctrineFixturesBundle
2
2
======================
3
3
4
- Fixtures are used to load a controlled set of data into a database. This data
5
- can be used for testing or could be the initial data required for the
6
- application to run smoothly . Symfony2 has no built in way to manage fixtures
7
- but Doctrine2 has a library to help you write fixtures for the Doctrine
8
- :doc: `ORM</book/doctrine> ` or :doc: `ODM</bundles/DoctrineMongoDBBundle/index> `.
4
+ Fiksni podatki (t.i. fixtures) so uporabljeni za nalaganje krmiljenega skupka podatkov v podatkovno bazo. Ti podatki
5
+ so lahko uporabljeni za testiranje ali so lahko začetni podatki zahtevani, da
6
+ aplikacija tekoče deluje . Symfony2 nima vgrajenega načina za upravljanje fiksnih podatkov,
7
+ vendar Doctrine2 ima knjižnico, ki vam pomaga pisati fiksne podatke za Doctrine
8
+ :doc: `ORM</book/doctrine> ` ali :doc: `ODM</bundles/DoctrineMongoDBBundle/index> `.
9
9
10
- Setup and Configuration
11
- -----------------------
10
+ Nastavitve in konfiguracija
11
+ ---------------------------
12
12
13
- Doctrine fixtures for Symfony are maintained in the `DoctrineFixturesBundle `_.
14
- The bundle uses external `Doctrine Data Fixtures `_ library .
13
+ Doctrine fiksni podatki za Symfony so vzdrževani v `DoctrineFixturesBundle `_.
14
+ Ta paket uporablja zunanjo knjižnico `Doctrine Data Fixtures `_.
15
15
16
- Follow these steps to install the bundle and the library in the Symfony
17
- Standard edition. Add the following to your ``composer.json `` file :
16
+ Sledite tem korakom za namestitev paketa in knjižnice v Symfony
17
+ standardno izdajo. Dodajte sledeče v vašo datoteko ``composer.json ``:
18
18
19
19
.. code-block :: json
20
20
@@ -24,22 +24,22 @@ Standard edition. Add the following to your ``composer.json`` file:
24
24
}
25
25
}
26
26
27
- Update the vendor libraries :
27
+ Posodobite knjižnice vendor:
28
28
29
29
.. code-block :: bash
30
30
31
31
$ php composer.phar update doctrine/doctrine-fixtures-bundle
32
32
33
- If everything worked, the ``DoctrineFixturesBundle `` can now be found
34
- at ``vendor/doctrine/doctrine-fixtures-bundle ``.
33
+ Če je vse delovalo v redu, je lahko sedaj ``DoctrineFixturesBundle `` najden
34
+ v ``vendor/doctrine/doctrine-fixtures-bundle ``.
35
35
36
36
.. note ::
37
37
38
- ``DoctrineFixturesBundle `` installs
39
- `Doctrine Data Fixtures `_ library. The library can be found
40
- at ``vendor/doctrine/data-fixtures ``.
38
+ ``DoctrineFixturesBundle `` namesti
39
+ knjižnico `Doctrine Data Fixtures `_. Knjižnico je moč najti
40
+ v ``vendor/doctrine/data-fixtures ``.
41
41
42
- Finally, register the Bundle ``DoctrineFixturesBundle `` in ``app/AppKernel.php ``.
42
+ Na koncu registrirajte paket ``DoctrineFixturesBundle `` v ``app/AppKernel.php ``.
43
43
44
44
.. code-block :: php
45
45
@@ -54,21 +54,21 @@ Finally, register the Bundle ``DoctrineFixturesBundle`` in ``app/AppKernel.php``
54
54
// ...
55
55
}
56
56
57
- Writing Simple Fixtures
58
- -----------------------
57
+ Pisanje enostavnih fiksnih podatkov
58
+ -----------------------------------
59
59
60
- Doctrine2 fixtures are PHP classes where you can create objects and persist
61
- them to the database. Like all classes in Symfony2, fixtures should live inside
62
- one of your application bundles .
60
+ Doctrine2 fiksni podatki so razredi PHP, kjer lahko ustvarite objekte in jih podate
61
+ v podatkovno bazo. Kot vsi razredi v Symfony2 bi morali fiksni podatki obstojati znotraj
62
+ enega izmed vaših paketov aplikacije .
63
63
64
- For a bundle located at ``src/Acme/HelloBundle ``, the fixture classes
65
- should live inside ``src/Acme/HelloBundle/DataFixtures/ORM `` or
66
- ``src/Acme/HelloBundle/DataFixtures/MongoDB `` respectively for the ORM and ODM,
67
- This tutorial assumes that you are using the ORM - but fixtures can be added
68
- just as easily if you're using the ODM.
64
+ Za paket lociran v ``src/Acme/HelloBundle `` bi se morali razredi fiksnih podatkov
65
+ nahajati znotraj ``src/Acme/HelloBundle/DataFixtures/ORM `` ali
66
+ ``src/Acme/HelloBundle/DataFixtures/MongoDB `` za ORM in ODM.
67
+ Ta vodič predpostavlja, da uporabljate ORM - vendar fiksni podatki so lahko dodani
68
+ enako enostavno, če uporabljate ODM.
69
69
70
- Imagine that you have a ``User `` class, and you'd like to load one `` User ``
71
- entry :
70
+ Predstavljajte si, da imate razred ``User `` in bi želeli naložiti eno entiteto
71
+ `` User `` :
72
72
73
73
.. code-block :: php
74
74
@@ -96,66 +96,66 @@ entry:
96
96
}
97
97
}
98
98
99
- In Doctrine2, fixtures are just objects where you load data by interacting
100
- with your entities as you normally do. This allows you to create the exact
101
- fixtures you need for your application .
99
+ V Doctrine2 so fiksni podatki samo objekti, kjer naložite podatke z interakcijo
100
+ z vašimi entitetami kot to običajno naredite. To vam omogoča, da ustvarite točne
101
+ fiksne podatke, ki jih potrebujete za vašo aplikacijo .
102
102
103
- The most serious limitation is that you cannot share objects between fixtures .
104
- Later, you'll see how to overcome this limitation .
103
+ Najresnejša omejitev je, da ne morete deliti objektov med fiksnimi podatki .
104
+ Kasneje boste videli, kako to omejitev premagati .
105
105
106
- Executing Fixtures
107
- ------------------
106
+ Izvrševanje fiksnih podatkov
107
+ ----------------------------
108
108
109
- Once your fixtures have been written, you can load them via the command
110
- line by using the ``doctrine:fixtures:load `` command :
109
+ Ko so enkrat fiksni podatki bili napisani, jih lahko naložite preko ukazne
110
+ vrstice z uporabo ukaza ``doctrine:fixtures:load ``:
111
111
112
112
.. code-block :: bash
113
113
114
114
php app/console doctrine:fixtures:load
115
115
116
- If you're using the ODM, use the ``doctrine:mongodb:fixtures:load `` command instead :
116
+ Če uporabljate ODM, uporabite namesto tega ukaz ``doctrine:mongodb:fixtures:load ``:
117
117
118
118
.. code-block :: bash
119
119
120
120
php app/console doctrine:mongodb:fixtures:load
121
121
122
- The task will look inside the ``DataFixtures/ORM `` (or ``DataFixtures/MongoDB ``
123
- for the ODM) directory of each bundle and execute each class that implements
124
- the ``FixtureInterface ``.
122
+ Opravilo bo pogledalo znotraj ``DataFixtures/ORM `` (ali ``DataFixtures/MongoDB ``
123
+ za ODM) direktorij za vsak paket in izvršilo vsak razred, ki implementira
124
+ ``FixtureInterface ``.
125
125
126
- Both commands come with a few options :
126
+ Oba ukaza prihajata z nekaj opcijami :
127
127
128
- * ``--fixtures=/path/to/fixture `` - Use this option to manually specify the
129
- directory where the fixtures classes should be loaded ;
128
+ * ``--fixtures=/path/to/fixture `` - Uporabite to opcijo, da ročno določite
129
+ direktorij, kjer bi morali biti naloženi razredi fiksnih podatkov ;
130
130
131
- * ``--append `` - Use this flag to append data instead of deleting data before
132
- loading it (deleting first is the default behavior );
131
+ * ``--append `` - Uporabite to zastavico, da pripnete podatke namesto brisanja podatkov pred
132
+ nalaganjem (brisanje najprej je privzeto obnašanje );
133
133
134
- * ``--em=manager_name `` - Manually specify the entity manager to use for
135
- loading the data .
134
+ * ``--em=manager_name `` - Ročno določite upravljalnika entitet za uporabo pri
135
+ nalaganju podatkov .
136
136
137
137
.. note ::
138
138
139
- If using the ``doctrine:mongodb:fixtures:load `` task, replace the ``--em= ``
140
- option with ``--dm= `` to manually specify the document manager .
139
+ Če uporabljate opravilo ``doctrine:mongodb:fixtures:load ``, zamenjajte opcijo ``--em= ``
140
+ z ``--dm= ``, da ročno določite upravljalnika dokumenta .
141
141
142
- A full example use might look like this :
142
+ Celotni primer uporabe lahko izgleda takole :
143
143
144
144
.. code-block :: bash
145
145
146
146
php app/console doctrine:fixtures:load --fixtures=/path/to/fixture1 --fixtures=/path/to/fixture2 --append --em=foo_manager
147
147
148
- Sharing Objects between Fixtures
149
- --------------------------------
148
+ Deljenje objektov med fiksnimi podatki
149
+ --------------------------------------
150
150
151
- Writing a basic fixture is simple. But what if you have multiple fixture classes
152
- and want to be able to refer to the data loaded in other fixture classes ?
153
- For example, what if you load a ``User `` object in one fixture, and then
154
- want to refer to reference it in a different fixture in order to assign that
155
- user to a particular group ?
151
+ Pisanje osnovnih fiksnih podatkov je enostavno. Vendar kaj, če imate več razredov fiksnih podatkov
152
+ in želite biti zmožni se sklicevati na podatke naložene v drugih razredih fiksnih podatkov ?
153
+ Na primer, kaj če želite naložiti objekt ``User `` v enem fiksnem podatki in nato
154
+ se želite sklicevati na njegov sklic v drugem fiksnem podatku, da določite tega uporabnika
155
+ določeni skupini ?
156
156
157
- The Doctrine fixtures library handles this easily by allowing you to specify
158
- the order in which fixtures are loaded .
157
+ Knjižnica Doctrine fixtures upravlja s tem enostavno z omogočanjem vam, da določite
158
+ vrstni red v katerem so fiksni podatki naloženi .
159
159
160
160
.. code-block :: php
161
161
@@ -193,10 +193,10 @@ the order in which fixtures are loaded.
193
193
}
194
194
}
195
195
196
- The fixture class now implements ``OrderedFixtureInterface ``, which tells
197
- Doctrine that you want to control the order of your fixtures. Create another
198
- fixture class and make it load after ``LoadUserData `` by returning an order
199
- of 2:
196
+ Razred fiksnih podatkov sedaj implementira ``OrderedFixtureInterface ``, ki pove
197
+ Doctrine, da želite kontrolirati vrstni red vaših fiksnih podatkov. Ustvarite drug
198
+ razred fiksnih podatkov in ga naložite za ``LoadUserData `` z vračilom vrstnega reda
199
+ 2:
200
200
201
201
.. code-block :: php
202
202
@@ -234,11 +234,11 @@ of 2:
234
234
}
235
235
}
236
236
237
- Both of the fixture classes extend ``AbstractFixture ``, which allows you
238
- to create objects and then set them as references so that they can be used
239
- later in other fixtures. For example, the ``$userAdmin `` and ``$groupAdmin ``
240
- objects can be referenced later via the ``admin-user `` and `` admin-group ``
241
- references :
237
+ Oba razreda fiksnih podatkov razširjata ``AbstractFixture ``, ki vam omogočata
238
+ ustvariti objekte in jih nato nastaviti kot sklice, da sta lahko uporabljena
239
+ kasneje v drugih fiksnih podatkih. Na primer objekta ``$userAdmin `` in ``$groupAdmin ``
240
+ sta lahko sklicana kasneje preko sklicev ``admin-user `` in
241
+ `` admin-group `` :
242
242
243
243
.. code-block :: php
244
244
@@ -275,26 +275,26 @@ references:
275
275
}
276
276
}
277
277
278
- The fixtures will now be executed in the ascending order of the value returned
279
- by ``getOrder() ``. Any object that is set with the ``setReference() `` method
280
- can be accessed via ``getReference() `` in fixture classes that have a higher
281
- order .
278
+ Fiksni podatki bodo sedaj izvršeni v naraščajočem vrstnem redu vrnjene vrednosti
279
+ z ``getOrder() ``. Katerikoli objekt, ki je nastavljen z metodo ``setReference() ``
280
+ je lahko dostopan preko ``getReference() `` v razredu fiksnih podatkov, ki imajo višji
281
+ vrstni red .
282
282
283
- Fixtures allow you to create any type of data you need via the normal PHP
284
- interface for creating and persisting objects. By controlling the order of
285
- fixtures and setting references, almost anything can be handled by fixtures .
283
+ Fiksni podatki vam omogočajo ustvariti kakršnikoli tip podatkov potrebujete preko običajnega PHP
284
+ vmesnika za izdelavo in pridobivanje objektov. S krmiljenjem vrstnega reda
285
+ fiksnih podatkov in nastavitvijo sklicev je lahko skoraj vse upravljano s strani fiksnih podatkov .
286
286
287
- Using the Container in the Fixtures
288
- -----------------------------------
287
+ Uporaba kontejnerja v fiksnih podatkih
288
+ --------------------------------------
289
289
290
- In some cases you may need to access some services to load the fixtures .
291
- Symfony2 makes it really easy: the container will be injected in all fixture
292
- classes implementing :class: `Symfony\\ Component\\ DependencyInjection\\ ContainerAwareInterface `.
290
+ V nekaterih primerih boste morda potrebovali dostopati do storitev in naložiti fiksne podatke .
291
+ Symfony2 naredi to res enostavno: kontejner bo injiciran v vse
292
+ razrede fiksnih podatkov, ki implementirajo :class: `Symfony\\ Component\\ DependencyInjection\\ ContainerAwareInterface `.
293
293
294
- Let's rewrite the first fixture to encode the password before it's stored
295
- in the database (a very good practice ). This will use the encoder factory
296
- to encode the password, ensuring it is encoded in the way used by the security
297
- component when checking it :
294
+ Prepišimo prvi fiksni podatek za enkodiranje gesla preden je shranjen
295
+ v podatkovno bazo (zelo dobra praksa ). To bo uporabilo tovarno enkoder
296
+ za enkodiranje gesla in zagotavljalo, da je enkodirano na način uporabljen s strani varnostne
297
+ komponente, ko se ga preverja :
298
298
299
299
.. code-block :: php
300
300
@@ -343,17 +343,17 @@ component when checking it:
343
343
}
344
344
}
345
345
346
- As you can see, all you need to do is add :class: `Symfony\\ Component\\ DependencyInjection\\ ContainerAwareInterface `
347
- to the class and then create a new :method: `Symfony\\ Component\\ DependencyInjection\\ ContainerInterface::setContainer `
348
- method that implements that interface. Before the fixture is executed, Symfony
349
- will call the :method: `Symfony\\ Component\\ DependencyInjection\\ ContainerInterface::setContainer `
350
- method automatically. As long as you store the container as a property on the
351
- class (as shown above ), you can access it in the ``load() `` method .
346
+ Kot vidite, je vse kar je potrebno dodati, :class: `Symfony\\ Component\\ DependencyInjection\\ ContainerAwareInterface `
347
+ razredu in nato ustvariti novo metodo :method: `Symfony\\ Component\\ DependencyInjection\\ ContainerInterface::setContainer `,
348
+ ki implementira ta vmesnik. Preden je fiksni podatek izvršen, bo Symfony
349
+ poklical metodo :method: `Symfony\\ Component\\ DependencyInjection\\ ContainerInterface::setContainer `
350
+ avtomatično. Dokler shranjujete kontejner kot lastnost na
351
+ razredu (kot prikazano zgoraj ), lahko do njega dostopate v metodi ``load() ``.
352
352
353
353
.. note ::
354
354
355
- If you are too lazy to implement the needed method :method: `Symfony\\ Component\\ DependencyInjection\\ ContainerInterface::setContainer `,
356
- you can then extend your class with :class: `Symfony\\ Component\\ DependencyInjection\\ ContainerAware `.
355
+ Če ste preveč leni za implementacijo potrebne metode :method: `Symfony\\ Component\\ DependencyInjection\\ ContainerInterface::setContainer `,
356
+ lahko vaš razred razširite z :class: `Symfony\\ Component\\ DependencyInjection\\ ContainerAware `.
357
357
358
358
.. _DoctrineFixturesBundle : https://github.com/doctrine/DoctrineFixturesBundle
359
359
.. _`Doctrine Data Fixtures` : https://github.com/doctrine/data-fixtures
0 commit comments