mirror of
https://github.com/DesignPatternsPHP/DesignPatternsPHP.git
synced 2025-09-03 03:32:49 +02:00
# msgid "" msgstr "" "Project-Id-Version: DesignPatternsPHP 1.0\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2015-05-29 12:18+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Language-Team: LANGUAGE <LL@li.org>\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #: ../../Structural/DependencyInjection/README.rst:2 msgid "`Dependency Injection`__" msgstr "`依赖注入`" #: ../../Structural/DependencyInjection/README.rst:5 msgid "Purpose" msgstr "目的" #: ../../Structural/DependencyInjection/README.rst:7 msgid "" "To implement a loosely coupled architecture in order to get better testable," " maintainable and extendable code." msgstr "实现了松耦合的软件架构,可得到更好的测试,管理和扩展的代码" #: ../../Structural/DependencyInjection/README.rst:11 msgid "Usage" msgstr "用例" #: ../../Structural/DependencyInjection/README.rst:13 msgid "" "``DatabaseConfiguration`` gets injected and ``DatabaseConnection`` will get all that it needs from " "``$config``. Without DI, the configuration would be created directly in ``DatabaseConnection``, which is " "not very good for testing and extending it." msgstr "" "通过配置需要注入的依赖,``Connection`` 能从 ``$config`` 中获取到所有它需要的依赖。如果没有" "依赖注入,``Connection`` 会直接创建它需要的依赖,这样不利于测试和扩展 ``Connection``。" #: ../../Structural/DependencyInjection/README.rst:18 msgid "" "Notice we are following Inversion of control principle in ``Connection`` by " "asking ``$config`` to implement ``Parameters`` interface. This decouples our" " components. We don't care where the source of information comes from, we " "only care that ``$config`` has certain methods to retrieve that information." " Read more about Inversion of control `here " "<http://en.wikipedia.org/wiki/Inversion_of_control>`__." msgstr "" "注意我们一直在遵循控制反转的设计原则,``Connection`` 通过要求 ``$config`` 实现 ``Parameters`` 的接口。这样就达到了组建间" "的解耦。我们不需要关心信息的来源,只需要关心 ``$config`` 中一定有方法来获取我们需要的信息。" "阅读更多的关于控制反转的资料请点" " `这里<http://en.wikipedia.org/wiki/Inversion_of_control>`__." #: ../../Structural/DependencyInjection/README.rst:26 msgid "Examples" msgstr "例子" #: ../../Structural/DependencyInjection/README.rst:28 msgid "" "The Doctrine2 ORM uses dependency injection e.g. for configuration that is " "injected into a ``Connection`` object. For testing purposes, one can easily " "create a mock object of the configuration and inject that into the " "``Connection`` object" msgstr "" "Doctrine2 ORM 使用了依赖注入,它通过配置注入了 ``Connection`` 对象。为了达到方便测试的目的," "可以很容易的通过配置创建一个mock的 ``Connection`` 对象。" #: ../../Structural/DependencyInjection/README.rst:32 msgid "" "many frameworks already have containers for DI that create " "objects via a configuration array and inject them where needed (i.e. in " "Controllers)" msgstr "" #: ../../Structural/DependencyInjection/README.rst:37 msgid "UML Diagram" msgstr "UML 图" #: ../../Structural/DependencyInjection/README.rst:44 msgid "Code" msgstr "代码" #: ../../Structural/DependencyInjection/README.rst:46 msgid "You can also find this code on `GitHub`_" msgstr "你可以在 `GitHub`_ 上找到这些代码" #: ../../Structural/DependencyInjection/README.rst:73 msgid "Test" msgstr "测试"