From abea9963962dda19722a976b4e995ffefdde9ac0 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Wed, 11 Jan 2017 10:12:28 +0100 Subject: [PATCH 1/5] File loadres can now set the type to load explicitly --- components/config/resources.rst | 16 ++++++++++++---- components/dependency_injection.rst | 9 +++++++++ 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/components/config/resources.rst b/components/config/resources.rst index 97924703158..ae4afa4135e 100644 --- a/components/config/resources.rst +++ b/components/config/resources.rst @@ -87,8 +87,16 @@ the resource:: $loaderResolver = new LoaderResolver(array(new YamlUserLoader($locator))); $delegatingLoader = new DelegatingLoader($loaderResolver); - $delegatingLoader->load(__DIR__.'/users.yml'); - /* - The YamlUserLoader will be used to load this resource, + // YamlUserLoader is used to load this resource because it supports + // files with the '.yml' extension since it supports files with a "yml" extension - */ + $delegatingLoader->load(__DIR__.'/users.yml'); + +.. tip:: + + If your application uses unconventional file extensions (for example, your + YAML files have a ``.res`` extension) you can pass the file type as the + second optional parameter of the ``load()`` method:: + + // ... + $delegatingLoader->load(__DIR__.'/users.res', 'yml'); diff --git a/components/dependency_injection.rst b/components/dependency_injection.rst index 7b50076940a..7fd83dd1cb5 100644 --- a/components/dependency_injection.rst +++ b/components/dependency_injection.rst @@ -216,6 +216,15 @@ Loading a YAML config file:: If you want to load YAML config files then you will also need to install :doc:`the Yaml component `. +.. tip:: + + If your application uses unconventional file extensions (for example, your + XML files have a ``.config`` extension) you can pass the file type as the + second optional parameter of the ``load()`` method:: + + // ... + $loader->load('services.config', 'xml'); + If you *do* want to use PHP to create the services then you can move this into a separate config file and load it in a similar way:: From bc720e8521821254dddab679829cf87ce16cd675 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Thu, 12 Jan 2017 11:05:34 +0100 Subject: [PATCH 2/5] The "type" option doesn't work in Config loaders --- components/config/resources.rst | 9 --------- 1 file changed, 9 deletions(-) diff --git a/components/config/resources.rst b/components/config/resources.rst index ae4afa4135e..64630c34fba 100644 --- a/components/config/resources.rst +++ b/components/config/resources.rst @@ -91,12 +91,3 @@ the resource:: // files with the '.yml' extension since it supports files with a "yml" extension $delegatingLoader->load(__DIR__.'/users.yml'); - -.. tip:: - - If your application uses unconventional file extensions (for example, your - YAML files have a ``.res`` extension) you can pass the file type as the - second optional parameter of the ``load()`` method:: - - // ... - $delegatingLoader->load(__DIR__.'/users.res', 'yml'); From a4f3354fb642e52bd9ef67faf076e82c13744b4c Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Thu, 12 Jan 2017 11:06:48 +0100 Subject: [PATCH 3/5] Fixed the indentation of the code block --- components/dependency_injection.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/dependency_injection.rst b/components/dependency_injection.rst index 7fd83dd1cb5..cc20d5f8dce 100644 --- a/components/dependency_injection.rst +++ b/components/dependency_injection.rst @@ -222,8 +222,8 @@ Loading a YAML config file:: XML files have a ``.config`` extension) you can pass the file type as the second optional parameter of the ``load()`` method:: - // ... - $loader->load('services.config', 'xml'); + // ... + $loader->load('services.config', 'xml'); If you *do* want to use PHP to create the services then you can move this into a separate config file and load it in a similar way:: From c05ca14151676a76014be53096c6f615cb258ea3 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Thu, 12 Jan 2017 11:10:57 +0100 Subject: [PATCH 4/5] Added an "import" example --- configuration.rst | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/configuration.rst b/configuration.rst index a72c8a9313b..11e97923b8d 100644 --- a/configuration.rst +++ b/configuration.rst @@ -181,6 +181,48 @@ The ``imports`` key works a lot like the PHP ``include()`` function: the content ``parameters.yml``, ``security.yml`` and ``services.yml`` are read and loaded. You can also load XML files or PHP files. +.. tip:: + + If your application uses unconventional file extensions (for example, your + YAML files have a ``.res`` extension) you can set the file type explicitly + with the ``type`` option: + + .. configuration-block:: + + .. code-block:: yaml + + # app/config/config.yml + imports: + - { resource: parameters.res, type: yml } + # ... + + .. code-block:: xml + + + + + + + + + + + + .. code-block:: php + + // app/config/config.php + $this->import('parameters.res', 'yml'); + // ... + .. _config-parameter-intro: The parameters Key: Parameters (Variables) From e54705341cbaedfc56d89e5a6c5ce181533808b8 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Thu, 12 Jan 2017 12:55:27 +0100 Subject: [PATCH 5/5] Removed a leftover content --- components/config/resources.rst | 1 - 1 file changed, 1 deletion(-) diff --git a/components/config/resources.rst b/components/config/resources.rst index 64630c34fba..de88b483b42 100644 --- a/components/config/resources.rst +++ b/components/config/resources.rst @@ -89,5 +89,4 @@ the resource:: // YamlUserLoader is used to load this resource because it supports // files with the '.yml' extension - since it supports files with a "yml" extension $delegatingLoader->load(__DIR__.'/users.yml');