8000 Merge branch '4.2' · symfony/symfony-docs@dbb41f1 · GitHub
[go: up one dir, main page]

Skip to content
8000

Commit dbb41f1

Browse files
committed
Merge branch '4.2'
* 4.2: Fixed typo in reference [#11108] Add inline code for the filename Update form_login_setup.rst Update dotenv.rst [Form] Add example for createNamed Form Update Traverse.rst
2 parents bb6266a + 06e5532 commit dbb41f1

File tree

4 files changed

+68
-7
lines changed

4 files changed

+68
-7
lines changed

components/dotenv.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ The Dotenv Component
66
====================
77

88
The Dotenv Component parses ``.env`` files to make environment variables
9-
stored in them accessible via ``getenv()``, ``$_ENV`` or ``$_SERVER``.
9+
stored in them accessible via ``$_ENV`` or ``$_SERVER``.
1010

1111
Installation
1212
------------
@@ -51,10 +51,10 @@ Given the following ``.env`` file content:
5151
DB_USER=root
5252
DB_PASS=pass
5353
54-
Access the value with ``getenv()`` in your code::
54+
Access the value with ``$_ENV`` in your code::
5555

56-
$dbUser = getenv('DB_USER');
57-
// you can also use ``$_ENV`` or ``$_SERVER``
56+
$dbUser = $_ENV['DB_USER'];
57+
// you can also use ``$_SERVER``
5858

5959
The ``load()`` method never overwrites existing environment variables. Use the
6060
``overload()`` method if you need to overwrite them::

forms.rst

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -691,7 +691,23 @@ the choice is ultimately up to you.
691691
.. note::
692692

693693
The form name is automatically generated from the type class name. If you want
694-
to modify it, use the :method:`Symfony\\Component\\Form\\FormFactoryInterface::createNamed` method.
694+
to modify it, use the :method:`Symfony\\Component\\Form\\FormFactoryInterface::createNamed` method::
695+
696+
// src/AppBundle/Controller/DefaultController.php
697+
use AppBundle\Form\TaskType;
698+
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
699+
700+
class DefaultController extends AbstractController
701+
{
702+
public function newAction()
703+
{
704+
$task = ...;
705+
$form = $this->get('form.factory')->createNamed('name', TaskType::class, $task);
706+
707+
// ...
708+
}
709+
}
710+
695711
You can even suppress the name completely by setting it to an empty string.
696712

697713
Final Thoughts

reference/constraints/Traverse.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ Traverse
44
Objects do not validate nested objects by default unless explicitly using
55
this constraint.
66
If only specific nested objects should be validated by cascade, consider
7-
using the :doc:`references/constraints/Valid` instead.
7+
using the :doc:`reference/constraints/Valid` instead.
88

99
+----------------+-------------------------------------------------------------------------------------+
1010
| Applies to | :ref:`class <validation-class-target>` |
1111
+----------------+-------------------------------------------------------------------------------------+
1212
| Options | - `payload`_ |
1313
+----------------+-------------------------------------------------------------------------------------+
14-
| Class | :class:`Symfony\\Bridge\\Doctrine\\Validator\\Constraints\\Traverse` |
14+
| Class | :class:`Symfony\Component\Validator\Constraints\Traverse` |
1515
+----------------+-------------------------------------------------------------------------------------+
1616

1717
Basic Usage

security/form_login_setup.rst

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,51 @@ class that processes the login submit and 4) updates the main security config fi
7474
}
7575
}
7676

77+
Edit the ``security.yml`` file in order to allow access for anyone to the
78+
``/login`` route:
79+
80+
.. configuration-block::
81+
82+
.. code-block:: yaml
83+
84+
# config/packages/security.yaml
85+
security:
86+
# ...
87+
88+
access_control:
89+
- { path: ^/login$, roles: IS_AUTHENTICATED_ANONYMOUSLY }
90+
# ...
91+
92+
.. code-block:: xml
93+
94+
<!-- config/packages/security.xml -->
95+
<?xml version="1.0" charset="UTF-8" ?>
96+
<srv:container xmlns="http://symfony.com/schema/dic/security"
97+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
98+
xmlns:srv="http://symfony.com/schema/dic/services"
99+
xsi:schemaLocation="http://symfony.com/schema/dic/services
100+
http://symfony.com/schema/dic/services/services-1.0.xsd">
101+
102+
<config>
103+
<rule path="^/login$" role="IS_AUTHENTICATED_ANONYMOUSLY" />
104+
<!-- ... -->
105+
</config>
106+
</srv:container>
107+
108+
.. code-block:: php
109+
110+
// config/packages/security.php
111+
$container->loadFromExtension('security', [
112+
// ...
113+
'access_control' => [
114+
[
115+
'path' => '^/login',
116+
'roles' => 'IS_AUTHENTICATED_ANONYMOUSLY',
117+
],
118+
// ...
119+
],
120+
]);
4BE8 121+
77122
**Step 2.** The template has very little to do with security: it just generates
78123
a traditional HTML form that submits to ``/login``:
79124

0 commit comments

Comments
 (0)
0