Skip to content

Commit b8e229b

Browse files
samdarkgithub-actions[bot]
authored andcommitted
Update translation
1 parent 209bae9 commit b8e229b

7 files changed

Lines changed: 230 additions & 188 deletions

File tree

_translations/po/es/guide_concept_di-container.md.po

Lines changed: 55 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
msgid ""
77
msgstr ""
88
"Project-Id-Version: PACKAGE VERSION\n"
9-
"POT-Creation-Date: 2025-09-11 10:15+0500\n"
9+
"POT-Creation-Date: 2026-01-16 07:58+0000\n"
1010
"PO-Revision-Date: 2025-09-04 07:37+0500\n"
1111
"Last-Translator: Automatically generated\n"
1212
"Language-Team: none\n"
@@ -17,29 +17,29 @@ msgstr ""
1717
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
1818

1919
#. type: Title #
20-
#: ../../guide/en/concept/di-container.md
20+
#: ../src/guide/concept/di-container.md
2121
#, no-wrap
2222
msgid "Dependency injection and container"
2323
msgstr ""
2424

2525
#. type: Title ##
26-
#: ../../guide/en/concept/di-container.md
26+
#: ../src/guide/concept/di-container.md
2727
#, no-wrap
2828
msgid "Dependency injection <span id=\"dependency-injection\"></span>"
2929
msgstr ""
3030

3131
#. type: Plain text
32-
#: ../../guide/en/concept/di-container.md
32+
#: ../src/guide/concept/di-container.md
3333
msgid "There are two ways of re-using things in OOP: inheritance and composition."
3434
msgstr ""
3535

3636
#. type: Plain text
37-
#: ../../guide/en/concept/di-container.md
37+
#: ../src/guide/concept/di-container.md
3838
msgid "Inheritance is simple:"
3939
msgstr ""
4040

4141
#. type: Fenced code block (php)
42-
#: ../../guide/en/concept/di-container.md
42+
#: ../src/guide/concept/di-container.md
4343
#, no-wrap
4444
msgid ""
4545
"class Cache\n"
@@ -64,17 +64,17 @@ msgid ""
6464
msgstr ""
6565

6666
#. type: Plain text
67-
#: ../../guide/en/concept/di-container.md
67+
#: ../src/guide/concept/di-container.md
6868
msgid "The issue here is that these two are becoming unnecessarily coupled or inter-dependent, making them more fragile."
6969
msgstr ""
7070

7171
#. type: Plain text
72-
#: ../../guide/en/concept/di-container.md
72+
#: ../src/guide/concept/di-container.md
7373
msgid "Another way to handle this is composition:"
7474
msgstr ""
7575

7676
#. type: Fenced code block (php)
77-
#: ../../guide/en/concept/di-container.md
77+
#: ../src/guide/concept/di-container.md
7878
#, no-wrap
7979
msgid ""
8080
"interface CacheInterface\n"
@@ -110,130 +110,138 @@ msgid ""
110110
msgstr ""
111111

112112
#. type: Plain text
113-
#: ../../guide/en/concept/di-container.md
113+
#: ../src/guide/concept/di-container.md
114114
msgid "We've avoided unnecessary inheritance and used interface to reduce coupling. You can replace cache implementation without changing `CachedWidget` so it's becoming more stable."
115115
msgstr ""
116116

117117
#. type: Plain text
118-
#: ../../guide/en/concept/di-container.md
118+
#: ../src/guide/concept/di-container.md
119119
msgid "The `CacheInterface` here is a dependency: an object another object depends on. The process of putting an instance of dependency into an object (`CachedWidget`) is called dependency injection. There are many ways to perform it:"
120120
msgstr ""
121121

122122
#. type: Bullet: '- '
123-
#: ../../guide/en/concept/di-container.md
123+
#: ../src/guide/concept/di-container.md
124124
msgid "Constructor injection. Best for mandatory dependencies."
125125
msgstr ""
126126

127127
#. type: Bullet: '- '
128-
#: ../../guide/en/concept/di-container.md
128+
#: ../src/guide/concept/di-container.md
129129
msgid "Method injection. Best for optional dependencies."
130130
msgstr ""
131131

132132
#. type: Bullet: '- '
133-
#: ../../guide/en/concept/di-container.md
133+
#: ../src/guide/concept/di-container.md
134134
msgid "Property injection. Better to be avoided in PHP except maybe data transfer objects."
135135
msgstr ""
136136

137137
#. type: Title ###
138-
#: ../../guide/en/concept/di-container.md
138+
#: ../src/guide/concept/di-container.md
139139
#, no-wrap
140140
msgid "Why use private properties <span id=\"why-private-properties\"></span>"
141141
msgstr ""
142142

143143
#. type: Plain text
144-
#: ../../guide/en/concept/di-container.md
144+
#: ../src/guide/concept/di-container.md
145145
msgid "In the composition example above, note that the `$cache` property is declared as `private`."
146146
msgstr ""
147147

148148
#. type: Plain text
149-
#: ../../guide/en/concept/di-container.md
149+
#: ../src/guide/concept/di-container.md
150150
msgid "This approach embraces composition by ensuring objects have well-defined interfaces for interaction rather than direct property access, making the code more maintainable and less prone to certain types of mistakes."
151151
msgstr ""
152152

153153
#. type: Plain text
154-
#: ../../guide/en/concept/di-container.md
154+
#: ../src/guide/concept/di-container.md
155155
msgid "This design choice provides several benefits:"
156156
msgstr ""
157157

158158
#. type: Bullet: '- '
159-
#: ../../guide/en/concept/di-container.md
159+
#: ../src/guide/concept/di-container.md
160160
msgid "**Encapsulation**: Private properties with getters/setters allow you to control access and make future changes without breaking existing code."
161161
msgstr ""
162162

163163
#. type: Bullet: '- '
164-
#: ../../guide/en/concept/di-container.md
164+
#: ../src/guide/concept/di-container.md
165165
msgid "**Data integrity**: Setters can validate, normalize, or format values before storing them, ensuring properties contain valid data."
166166
msgstr ""
167167

168168
#. type: Bullet: '- '
169-
#: ../../guide/en/concept/di-container.md
169+
#: ../src/guide/concept/di-container.md
170170
msgid "**Immutability**: Private properties enable immutable object patterns where setter `with*()` methods return new instances rather than modifying the current one."
171171
msgstr ""
172172

173173
#. type: Bullet: '- '
174-
#: ../../guide/en/concept/di-container.md
174+
#: ../src/guide/concept/di-container.md
175175
msgid "**Flexibility**: You can create read-only or write-only properties or add additional logic to property access later."
176176
msgstr ""
177177

178178
#. type: Title ##
179-
#: ../../guide/en/concept/di-container.md
179+
#: ../src/guide/concept/di-container.md
180180
#, no-wrap
181181
msgid "DI container <span id=\"di-container\"></span>"
182182
msgstr ""
183183

184184
#. type: Plain text
185-
#: ../../guide/en/concept/di-container.md
185+
#: ../src/guide/concept/di-container.md
186186
msgid "Injecting basic dependencies is straightforward. You're choosing a place where you don't care about dependencies, which is usually an action handler, which you aren't going to unit-test ever, create instances of dependencies needed and pass these to dependent classes."
187187
msgstr ""
188188

189189
#. type: Plain text
190-
#: ../../guide/en/concept/di-container.md
190+
#: ../src/guide/concept/di-container.md
191191
msgid "It works well when there are few dependencies overall and when there are no nested dependencies. When there are many and each dependency has dependencies itself, instantiating the whole hierarchy becomes a tedious process, which requires lots of code and may lead to hardly debuggable mistakes."
192192
msgstr ""
193193

194194
#. type: Plain text
195-
#: ../../guide/en/concept/di-container.md
195+
#: ../src/guide/concept/di-container.md
196196
msgid "Additionally, lots of dependencies, such as certain third-party API wrappers, are the same for any class using it. So it makes sense to:"
197197
msgstr ""
198198

199199
#. type: Bullet: '- '
200-
#: ../../guide/en/concept/di-container.md
200+
#: ../src/guide/concept/di-container.md
201201
msgid "Define how to instantiate such an API wrapper."
202202
msgstr ""
203203

204204
#. type: Bullet: '- '
205-
#: ../../guide/en/concept/di-container.md
205+
#: ../src/guide/concept/di-container.md
206206
msgid "Instantiate it when required and only once per request."
207207
msgstr ""
208208

209209
#. type: Plain text
210-
#: ../../guide/en/concept/di-container.md
210+
#: ../src/guide/concept/di-container.md
211211
msgid "That's what dependency containers are for."
212212
msgstr ""
213213

214214
#. type: Plain text
215-
#: ../../guide/en/concept/di-container.md
215+
#: ../src/guide/concept/di-container.md
216216
msgid "A dependency injection (DI) container is an object that knows how to instantiate and configure objects and all their dependent objects. [Martin Fowler's article](https://martinfowler.com/articles/injection.html) has well explained why DI container is useful. Here we will mainly explain the usage of the DI container provided by Yii."
217217
msgstr ""
218218

219219
#. type: Plain text
220-
#: ../../guide/en/concept/di-container.md
220+
#: ../src/guide/concept/di-container.md
221+
#, no-wrap
222+
msgid ""
223+
"> [!NOTE]\n"
224+
"> The container contains only shared instances. If you need a factory, use the dedicated [yiisoft/factory](https://github.com/yiisoft/factory) package.\n"
225+
msgstr ""
226+
227+
#. type: Plain text
228+
#: ../src/guide/concept/di-container.md
221229
msgid "Yii provides the DI container feature through the [yiisoft/di](https://github.com/yiisoft/di) package and [yiisoft/injector](https://github.com/yiisoft/injector) package."
222230
msgstr ""
223231

224232
#. type: Title ###
225-
#: ../../guide/en/concept/di-container.md
233+
#: ../src/guide/concept/di-container.md
226234
#, no-wrap
227235
msgid "Configuring container <span id=\"configuring-container\"></span>"
228236
msgstr ""
229237

230238
#. type: Plain text
231-
#: ../../guide/en/concept/di-container.md
239+
#: ../src/guide/concept/di-container.md
232240
msgid "Because to create a new object you need its dependencies, you should register them as early as possible. You can do it in the application configuration, `config/web.php`. For the following service:"
233241
msgstr ""
234242

235243
#. type: Fenced code block (php)
236-
#: ../../guide/en/concept/di-container.md
244+
#: ../src/guide/concept/di-container.md
237245
#, no-wrap
238246
msgid ""
239247
"final class MyService implements MyServiceInterface\n"
@@ -250,12 +258,12 @@ msgid ""
250258
msgstr ""
251259

252260
#. type: Plain text
253-
#: ../../guide/en/concept/di-container.md
261+
#: ../src/guide/concept/di-container.md
254262
msgid "configuration could be:"
255263
msgstr ""
256264

257265
#. type: Fenced code block (php)
258-
#: ../../guide/en/concept/di-container.md
266+
#: ../src/guide/concept/di-container.md
259267
#, no-wrap
260268
msgid ""
261269
"return [\n"
@@ -268,25 +276,25 @@ msgid ""
268276
msgstr ""
269277

270278
#. type: Plain text
271-
#: ../../guide/en/concept/di-container.md
279+
#: ../src/guide/concept/di-container.md
272280
msgid "That's equal to the following:"
273281
msgstr ""
274282

275283
#. type: Fenced code block (php)
276-
#: ../../guide/en/concept/di-container.md
284+
#: ../src/guide/concept/di-container.md
277285
#, no-wrap
278286
msgid ""
279287
"$myService = new MyService(42);\n"
280288
"$myService->setDiscount(10);\n"
281289
msgstr ""
282290

283291
#. type: Plain text
284-
#: ../../guide/en/concept/di-container.md
292+
#: ../src/guide/concept/di-container.md
285293
msgid "There are extra methods of declaring dependencies:"
286294
msgstr ""
287295

288296
#. type: Fenced code block (php)
289-
#: ../../guide/en/concept/di-container.md
297+
#: ../src/guide/concept/di-container.md
290298
#, no-wrap
291299
msgid ""
292300
"return [\n"
@@ -315,23 +323,23 @@ msgid ""
315323
msgstr ""
316324

317325
#. type: Title ###
318-
#: ../../guide/en/concept/di-container.md
326+
#: ../src/guide/concept/di-container.md
319327
#, no-wrap
320328
msgid "Injecting dependencies <span id=\"injecting-dependencies\"></span>"
321329
msgstr ""
322330

323331
#. type: Plain text
324-
#: ../../guide/en/concept/di-container.md
332+
#: ../src/guide/concept/di-container.md
325333
msgid "Directly referencing a container in a class is a bad idea since the code becomes non-generic, coupled to the container interface and, what's worse, dependencies are becoming hidden. Because of that, Yii inverts the control by automatically injecting objects from a container in some constructors and methods based on method argument types."
326334
msgstr ""
327335

328336
#. type: Plain text
329-
#: ../../guide/en/concept/di-container.md
337+
#: ../src/guide/concept/di-container.md
330338
msgid "This is primarily done in constructor and handing method of action handlers:"
331339
msgstr ""
332340

333341
#. type: Fenced code block (php)
334-
#: ../../guide/en/concept/di-container.md
342+
#: ../src/guide/concept/di-container.md
335343
#, no-wrap
336344
msgid ""
337345
"use \\Yiisoft\\Cache\\CacheInterface;\n"
@@ -359,17 +367,17 @@ msgid ""
359367
msgstr ""
360368

361369
#. type: Plain text
362-
#: ../../guide/en/concept/di-container.md
370+
#: ../src/guide/concept/di-container.md
363371
msgid "Since it's [yiisoft/injector](https://github.com/yiisoft/injector) that instantiates and calls action handler, it checks the constructor and method argument types, gets dependencies of these types from a container and passes them as arguments. That's usually called auto-wiring. It happens for sub-dependencies as well, that's if you don't give dependency explicitly, the container would check if it has such a dependency first. It's enough to declare a dependency you need, and it would be got from a container automatically."
364372
msgstr ""
365373

366374
#. type: Title ##
367-
#: ../../guide/en/concept/di-container.md
375+
#: ../src/guide/concept/di-container.md
368376
#, no-wrap
369377
msgid "References <span id=\"references\"></span>"
370378
msgstr ""
371379

372380
#. type: Bullet: '- '
373-
#: ../../guide/en/concept/di-container.md
381+
#: ../src/guide/concept/di-container.md
374382
msgid "[Inversion of Control Containers and the Dependency Injection pattern by Martin Fowler](https://martinfowler.com/articles/injection.html)"
375383
msgstr ""

0 commit comments

Comments
 (0)