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

Appearance settings

Commit 43fc4e1

Browse filesBrowse files
matthiasnobackweaverryan
authored andcommitted
Fixed typo's, replaced directory separators with slasges, changed commenting style
1 parent 7d04efa commit 43fc4e1
Copy full SHA for 43fc4e1

File tree

Expand file treeCollapse file tree

3 files changed

+28
-29
lines changed
Filter options
Expand file treeCollapse file tree

3 files changed

+28
-29
lines changed

‎components/config/caching.rst

Copy file name to clipboardExpand all lines: components/config/caching.rst
+19-17Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Caching based on resources
55
==========================
66

77
When all configuration resources are loaded, you may want to process the configuration values and
8-
combine them all in one file. This file acts like a cache. It’s contents don’t have to be
8+
combine them all in one file. This file acts like a cache. Its contents don’t have to be
99
regenerated every time the application runs – only when the configuration resources are modified.
1010

1111
For example, the Symfony Routing component allows you to load all routes, and then dump a URL
@@ -16,39 +16,41 @@ invalidated and regenerated. This can be accomplished by making use of the
1616

1717
The example below shows you how to collect resources, then generate some code based on the
1818
resources that were loaded, and write this code to the cache. The cache also receives the
19-
collection of resources that were used for generating the code. By looking at the last modified
20-
timestamp of these resources, the cache can tell if it is still fresh or that it’s contents should
19+
collection of resources that were used for generating the code. By looking at the "last modified"
20+
timestamp of these resources, the cache can tell if it is still fresh or that its contents should
2121
be regenerated.
2222

2323
.. code-block:: php
2424
2525
use Symfony\Component\Config\ConfigCache;
26+
use Symfony\Component\Config\Resource\FileResource;
2627
27-
// $yamlUserFiles is filled before with an array of 'users.yml' file paths
28-
29-
$resources = array();
30-
31-
foreach ($yamlUserFiles as $yamlUserFile) {
32-
$resources[] = new FileResource($yamlUserFile);
33-
}
34-
35-
$cachePath = __DIR__ . DIRECTORY_SEPARATOR . 'cache' . DIRECTORY_SEPARATOR . 'appUserMatcher.php';
28+
$cachePath = __DIR__.'/cache/appUserMatcher.php';
3629
3730
$userMatcherCache = new ConfigCache($cachePath, true);
3831
// the second constructor argument indicates whether or not we are in debug mode
3932
4033
if (!$userMatcherCache->isFresh()) {
41-
foreach ($resources as $resource) {
42-
$delegatingLoader->load($resource->getResource());
34+
// fill this with an array of 'users.yml' file paths
35+
$yamlUserFiles = ...;
36+
37+
$resources = array();
38+
39+
foreach ($yamlUserFiles as $yamlUserFile) {
40+
$delegatingLoader->load($yamlUserFile);
41+
$resources[] = new FileResource($yamlUserFile);
4342
}
4443
4544
// The code for the UserMatcher is generated elsewhere
46-
// $code = ...;
45+
$code = ...;
46+
4747
$userMatcherCache->write($code, $resources);
4848
}
4949
5050
// you may want to require the cached code:
5151
require $cachePath;
5252
53-
A ``.meta`` file is created in the same directory as the cache file itself. This ``.meta`` file
54-
contains the serialized resources, for later reference.
53+
In debug mode, a ``.meta`` file will be created in the same directory as the cache file itself.
54+
This ``.meta`` file contains the serialized resources, whose timestamps are used to determine if
55+
the cache is still fresh. When not in debug mode, the cache is considered to be "fresh" as soon
56+
as it exists, and therefore no ``.meta`` file will be generated.

‎components/config/definition.rst

Copy file name to clipboardExpand all lines: components/config/definition.rst
+5-8Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ from a custom ``Configuration`` class which implements the
6060
$treeBuilder = new TreeBuilder();
6161
$rootNode = $treeBuilder->root('database');
6262
63-
// add node definitions to the root of the tree
63+
// ... add node definitions to the root of the tree
6464
6565
return $treeBuilder;
6666
}
@@ -244,6 +244,7 @@ A validation rule always has an "if" part. You can specify this part in the foll
244244
- ``ifArray()``
245245
- ``ifInArray()``
246246
- ``ifNotInArray()``
247+
- ``always()``
247248

248249
A validation rule also requires a "then" part:
249250

@@ -252,12 +253,8 @@ A validation rule also requires a "then" part:
252253
- ``thenInvalid()``
253254
- ``thenUnset()``
254255

255-
The only exception is of course:
256-
257-
- ``always()``
258-
259-
Usually, “then” is a closure. It’s return value will be used as a new value for the node, instead
260-
of the node’s original value.
256+
Usually, "then" is a closure. Its return value will be used as a new value for the node, instead
257+
of the node's original value.
261258

262259
Processing configuration values
263260
-------------------------------
@@ -279,6 +276,6 @@ an exception will be thrown. Otherwise the result is a clean array of configurat
279276
280277
$configs = array($config1, $config2);
281278
282-
$processor = new Processor;
279+
$processor = new Processor();
283280
$configuration = new DatabaseConfiguration;
284281
$processedConfiguration = $processor->processConfiguration($configuration, $configs);

‎components/config/resources.rst

Copy file name to clipboardExpand all lines: components/config/resources.rst
+4-4Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ can be done with the :class:`Symfony\\Component\\Config\\FileLocator`:
1414
1515
use Symfony\Component\Config\FileLocator;
1616
17-
$configDirectories = array(__DIR__ . DIRECTORY_SEPARATOR . 'app' . DIRECTORY_SEPARATOR . 'config');
17+
$configDirectories = array(__DIR__.'/app/config');
1818
1919
$locator = new FileLocator($configDirectories);
2020
$yamlUserFiles = $locator->locate('users.yml', null, false);
@@ -44,7 +44,7 @@ importing other resources.
4444
{
4545
$configValues = Yaml::parse($resource);
4646
47-
// handle the config values
47+
// ... handle the config values
4848
4949
// maybe import some other resource:
5050
@@ -60,7 +60,7 @@ importing other resources.
6060
Finding the right loader
6161
------------------------
6262

63-
The :class:`Symfony\\Component\\Config\\Loader\\LoaderResolver` receives as it’s first constructor
63+
The :class:`Symfony\\Component\\Config\\Loader\\LoaderResolver` receives as its first constructor
6464
argument a collection of loaders. When a resource (for instance an XML file) should be loaded,
6565
it loops through this collection of loaders and returns the loader which supports this
6666
particular resource type.
@@ -77,7 +77,7 @@ In case the resolver has found a suitable loader, this loader will be asked to l
7777
$loaderResolver = new LoaderResolver(array(new YamlUserLoader));
7878
$delegatingLoader = new DelegatingLoader($loaderResolver);
7979
80-
$delegatingLoader->load(__DIR__ . DIRECTORY_SEPARATOR . '/users.yml');
80+
$delegatingLoader->load(__DIR__.'/users.yml');
8181
/*
8282
The YamlUserLoader will be used to load this resource,
8383
since it supports files with a "yml" extension

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.