Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit266e14e

Browse files
committed
feature#7353 File loaders can now set the type to load explicitly (javiereguiluz)
This PR was squashed before being merged into the master branch (closes#7353).Discussion----------File loaders can now set the type to load explicitlyThisfixes#7352.I propose to document this in a subtle manner because this is rarely needed by users.Ping@ogizanagi because he was the original author of the related PR. Thanks!Commits-------3562718 File loaders can now set the type to load explicitly
2 parents6e6962e +3562718 commit266e14e

File tree

3 files changed

+53
-4
lines changed

3 files changed

+53
-4
lines changed

‎components/config/resources.rst‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,6 @@ the resource::
8787
$loaderResolver = new LoaderResolver(array(new YamlUserLoader($locator)));
8888
$delegatingLoader = new DelegatingLoader($loaderResolver);
8989

90+
// YamlUserLoader is used to load this resource because it supports
91+
// files with the '.yml' extension
9092
$delegatingLoader->load(__DIR__.'/users.yml');
91-
/*
92-
The YamlUserLoader will be used to load this resource,
93-
since it supports files with a "yml" extension
94-
*/

‎components/dependency_injection.rst‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,15 @@ Loading a YAML config file::
216216
If you want to load YAML config files then you will also need to install
217217
:doc:`the Yaml component</components/yaml>`.
218218

219+
..tip::
220+
221+
If your application uses unconventional file extensions (for example, your
222+
XML files have a ``.config`` extension) you can pass the file type as the
223+
second optional parameter of the ``load()`` method::
224+
225+
// ...
226+
$loader->load('services.config', 'xml');
227+
219228
If you *do* want to use PHP to create the services then you can move this
220229
into a separate config file and load it in a similar way::
221230

‎configuration.rst‎

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,48 @@ The ``imports`` key works a lot like the PHP ``include()`` function: the content
181181
``parameters.yml``, ``security.yml`` and ``services.yml`` are read and loaded. You
182182
can also load XML files or PHP files.
183183

184+
..tip::
185+
186+
If your application uses unconventional file extensions (for example, your
187+
YAML files have a ``.res`` extension) you can set the file type explicitly
188+
with the ``type`` option:
189+
190+
..configuration-block::
191+
192+
..code-block::yaml
193+
194+
# app/config/config.yml
195+
imports:
196+
-{ resource: parameters.res, type: yml }
197+
# ...
198+
199+
..code-block::xml
200+
201+
<!-- app/config/config.xml-->
202+
<?xml version="1.0" encoding="UTF-8" ?>
203+
<containerxmlns="http://symfony.com/schema/dic/services"
204+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
205+
xmlns:framework="http://symfony.com/schema/dic/symfony"
206+
xmlns:twig="http://symfony.com/schema/dic/twig"
207+
xsi:schemaLocation="http://symfony.com/schema/dic/services
208+
http://symfony.com/schema/dic/services/services-1.0.xsd
209+
http://symfony.com/schema/dic/symfony
210+
http://symfony.com/schema/dic/symfony/symfony-1.0.xsd
211+
http://symfony.com/schema/dic/twig
212+
http://symfony.com/schema/dic/twig/twig-1.0.xsd">
213+
214+
<imports>
215+
<importresource="parameters.res"type="yml" />
216+
<!-- ...-->
217+
</imports>
218+
</container>
219+
220+
..code-block::php
221+
222+
// app/config/config.php
223+
$this->import('parameters.res', 'yml');
224+
// ...
225+
184226
.. _config-parameter-intro:
185227

186228
The parameters Key: Parameters (Variables)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp