Skip to content

Commit a271648

Browse files
committed
Merge branch '3.2'
* 3.2: Documented the getIterator() method [#7844] add XML and PHP config examples Property access fix remaining setDefinition() call mention old way to create PHPUnit mock objects Explain how to override the default templates directory Added a new article about linting translation files Removed any reference to X-Status-Code
2 parents cc3f107 + 89e5c4f commit a271648

File tree

8 files changed

+77
-14
lines changed

8 files changed

+77
-14
lines changed

components/process.rst

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,22 @@ for new output before going to the next iteration::
6565
}
6666
}
6767

68+
.. tip::
69+
70+
The Process component internally uses a PHP iterator to get the output while
71+
it is generated. That iterator is exposed via the ``getIterator()`` method
72+
to allow customizing its behavior::
73+
74+
$process = new Process('ls -lsa');
75+
$process->start();
76+
$iterator = $process->getIterator($process::ITER_SKIP_ERR | $process::ITER_KEEP_OUTPUT);
77+
foreach ($iterator as $data) {
78+
echo $data."\n";
79+
}
80+
81+
.. versionadded:: 3.2
82+
The ``getIterator()`` method was introduced in Symfony 3.2.
83+
6884
The ``mustRun()`` method is identical to ``run()``, except that it will throw
6985
a :class:`Symfony\\Component\\Process\\Exception\\ProcessFailedException`
7086
if the process couldn't be executed successfully (i.e. the process exited

configuration/override_dir_structure.rst

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ directory structure is:
1313
your-project/
1414
├─ app/
1515
│ ├─ config/
16+
│ ├─ Resources/
17+
│ │ └─ views/
1618
│ └─ ...
1719
├─ bin/
1820
│ └─ ...
@@ -86,6 +88,50 @@ method::
8688

8789
Here you have changed the location of the directory to ``var/{environment}/logs``.
8890

91+
.. _override-templates-dir:
92+
93+
Override the Templates Directory
94+
--------------------------------
95+
96+
If your templates are not stored in the default ``app/Resources/views/``
97+
directory, use the :ref:`twig.paths <config-twig-paths>` configuration option to
98+
define your own templates directory (or directories):
99+
100+
.. configuration-block::
101+
102+
.. code-block:: yaml
103+
104+
# app/config/config.yml
105+
twig:
106+
# ...
107+
paths: ["%kernel.root_dir%/../templates"]
108+
109+
.. code-block:: xml
110+
111+
<!-- app/config/config.xml -->
112+
<?xml version="1.0" ?>
113+
<container xmlns="http://symfony.com/schema/dic/services"
114+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
115+
xmlns:twig="http://symfony.com/schema/dic/twig"
116+
xsi:schemaLocation="http://symfony.com/schema/dic/services
117+
http://symfony.com/schema/dic/services/services-1.0.xsd
118+
http://symfony.com/schema/dic/twig
119+
http://symfony.com/schema/dic/twig/twig-1.0.xsd">
120+
121+
<twig:config>
122+
<twig:path>%kernel.root_dir%/../templates</twig:path>
123+
</twig:config>
124+
</container>
125+
126+
.. code-block:: php
127+
128+
// app/config/config.php
129+
$container->loadFromExtension('twig', array(
130+
'paths' => array(
131+
'%kernel.root_dir%/../templates',
132+
),
133+
));
134+
89135
.. _override-web-dir:
90136

91137
Override the ``web`` Directory

create_framework/unit_testing.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,9 @@ We are now ready to write our first test::
9797
private function getFrameworkForException($exception)
9898
{
9999
$matcher = $this->createMock(Routing\Matcher\UrlMatcherInterface::class);
100+
// use getMock() on PHPUnit 5.3 or below
101+
// $matcher = $this->getMock(Routing\Matcher\UrlMatcherInterface::class);
102+
100103
$matcher
101104
->expects($this->once())
102105
->method('match')
@@ -155,6 +158,9 @@ Response::
155158
public function testControllerResponse()
156159
{
157160
$matcher = $this->createMock(Routing\Matcher\UrlMatcherInterface::class);
161+
// use getMock() on PHPUnit 5.3 or below
162+
// $matcher = $this->getMock(Routing\Matcher\UrlMatcherInterface::class);
163+
158164
$matcher
159165
->expects($this->once())
160166
->method('match')

form/unit_testing.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,8 @@ allows you to return a list of extensions to register::
184184
protected function getExtensions()
185185
{
186186
$this->validator = $this->createMock(ValidatorInterface::class);
187+
// use getMock() on PHPUnit 5.3 or below
188+
// $this->validator = $this->getMock(ValidatorInterface::class);
187189
$this->validator
188190
->method('validate')
189191
->will($this->returnValue(new ConstraintViolationList()));

reference/configuration/twig.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,8 @@ on. Set it to ``0`` to disable all the optimizations. You can even enable or
248248
disable these optimizations selectively, as explained in the Twig documentation
249249
about `the optimizer extension`_.
250250

251+
.. _config-twig-paths:
252+
251253
paths
252254
~~~~~
253255

reference/events.rst

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -242,19 +242,8 @@ and set a new ``Exception`` object, or do nothing::
242242

243243
.. note::
244244

245-
If you want to overwrite the status code (which you should do not without a good
246-
reason), set the ``X-Status-Code`` header::
247-
248-
$response = new Response(
249-
'Error',
250-
404, // this status code will be ignored
251-
array(
252-
'X-Status-Code' => 200 // this status code will actually be sent to the client
253-
)
254-
);
255-
256-
If you do **not** set the ``X-Status-Code`` header, then Symfony uses the following
257-
logic to determine the status code:
245+
Symfony uses the following logic to determine the HTTP status code of the
246+
response:
258247

259248
* If :method:`Symfony\\Component\\HttpFoundation\\Response::isClientError`,
260249
:method:`Symfony\\Component\\HttpFoundation\\Response::isServerError` or

security/custom_authentication_provider.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,7 @@ to service ids that do not exist yet: ``wsse.security.authentication.provider``
460460
))
461461
->setPublic(false);
462462
463-
$container->setDefinition('wsse.security.authentication.listener', WsseListener::class)
463+
$container->register('wsse.security.authentication.listener', WsseListener::class)
464464
->setArguments(array(
465465
new Reference('security.token_storage'),
466466
new Reference('security.authentication.manager'),

testing/database.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ it's easy to pass a mock object within a test::
7575
{
7676
// First, mock the object to be used in the test
7777
$employee = $this->createMock(Employee::class);
78+
// use getMock() on PHPUnit 5.3 or below
79+
// $employee = $this->getMock(Employee::class);
7880
$employee->expects($this->once())
7981
->method('getSalary')
8082
->will($this->returnValue(1000));

0 commit comments

Comments
 (0)