8000 Fix classes generation with YAML or XML metadata. · symfony/symfony-docs@eb5cad3 · GitHub
[go: up one dir, main page]

Skip to content

Commit eb5cad3

Browse files
baioloxabbuh
authored andcommitted
Fix classes generation with YAML or XML metadata.
1 parent 0f94f96 commit eb5cad3

33 files changed

+224
-62
lines changed
-21.9 KB
Binary file not shown.

_images/components/messenger/overview.svg

Lines changed: 1 addition & 0 deletions
Loading
Binary file not shown.

_images/components/serializer/serializer_workflow.svg

Lines changed: 1 addition & 0 deletions
Loading

_images/http/request-flow.png

-75.3 KB
Binary file not shown.

_images/http/request-flow.svg

Lines changed: 1 addition & 0 deletions
Loading

_images/security/authentication-guard-methods.svg

Lines changed: 1 addition & 1 deletion
Loading
Binary file not shown.
Binary file not shown.

_images/sources/http/request-flow.dia

2.93 KB
Binary file not shown.
Binary file not shown.

components/console/events.rst

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -94,17 +94,6 @@ event listeners, the ``ConsoleEvents::ERROR`` event is dispatched. A listener
9494
can wrap or change the exception or do anything useful before the exception is
9595
thrown by the application.
9696

97-
The ``ConsoleEvents::ERROR`` Event
98-
----------------------------------
99-
100-
**Typical Purposes**: Handle exceptions thrown during the execution of a
101-
command.
102-
103-
Whenever an exception is thrown by a command, including those triggered from
104-
event listeners, the ``ConsoleEvents::ERROR`` event is dispatched. A listener
105-
can wrap or change the exception or do anything useful before the exception is
106-
thrown by the application.
107-
10897
Listeners receive a
10998
:class:`Symfony\\Component\\Console\\Event\\ConsoleErrorEvent` event::
11099

components/messenger.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ Alternatively, you can clone the `<https://github.com/symfony/messenger>`_ repos
3131
Concepts
3232
--------
3333

34-
.. image:: /_images/components/messenger/overview.png
34+
.. raw:: html
35+
36+
<object data="../_images/components/messenger/overview.svg" type="image/svg+xml"></object>
3537

3638
**Sender**:
3739
Responsible for serializing and sending messages to *something*. This

components/serializer.rst

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ The Serializer Component
1010

1111
In order to do so, the Serializer component follows the following schema.
1212

13-
.. image:: /_images/components/serializer/serializer_workflow.png
13+
.. raw:: html
14+
15+
<object data="../_images/components/serializer/serializer_workflow.svg" type="image/svg+xml"></object>
1416

1517
As you can see in the picture above, an array is used as an intermediary between
1618
objects and serialized contents. This way, encoders will only deal with turning
@@ -714,7 +716,7 @@ The ``XmlEncoder`` will encode this object like that::
714716
Be aware that this encoder will consider keys beginning with ``@`` as attributes::
715717

716718
$encoder = new XmlEncoder();
717-
$encoder->encode(array('foo' => array('@bar' => 'value')));
719+
$encoder->encode(array('foo' => array('@bar' => 'value')), 'xml');
718720
// will return:
719721
// <?xml version="1.0"?>
720722
// <response>

configuration.rst

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,8 +269,7 @@ You can also create a few other ``.env`` files that will be loaded:
269269
``prod`` environment but will *not* be committed to your repository.
270270

271271
If you decide to set real environment variables on production, the ``.env`` files
272-
will *not* be loaded if Symfony detects that a real ``APP_ENV`` environment variable
273-
exists and is set to ``prod``.
272+
*are* still loaded, but your real environment variables will override those values.
274273

275274
Environments & the Other Config Files
276275
-------------------------------------

configuration/dot-env-changes.rst

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,10 @@ important changes:
3030
other environments. You can also create a ``.env.test`` file for test-environment
3131
overrides.
3232

33-
* E) If you pass the ``--env=`` flag when running ``bin/console``, this value will
34-
override your ``APP_ENV`` environment variable (if set). And so, if you pass
35-
``--env=prod``, the DotEnv component *will* try to load your ``.env*`` files.
33+
* E) `One further change to the recipe in January 2019`_ means that your ``.env``
34+
files are *always* loaded, even if you set an ``APP_ENV=prod`` environment
35+
variable. The purpose is for the ``.env`` files to define default values that
36+
you can override if you want to with real environment values.
3637

3738
There are a few other improvements, but these are the most important. To take advantage
3839
of these, you *will* need to modify a few files in your existing app.
@@ -52,7 +53,7 @@ changes can be made to any Symfony 3.4 or higher app:
5253
file. If you've customized this file, make sure to keep those changes (but use
5354
the rest of the changes).
5455

55-
#. Update your `bin/console`_ (`bin/console diff`_) file to load the new ``config/bootstrap.php`` file.
56+
#. Update your `bin/console`_ file to load the new ``config/bootstrap.php`` file.
5657

5758
#. Update ``.gitignore``:
5859

@@ -64,6 +65,7 @@ changes can be made to any Symfony 3.4 or higher app:
6465
###> symfony/framework-bundle ###
6566
- /.env
6667
+ /.env.local
68+
+ /.env.local.php
6769
+ /.env.*.local
6870
6971
# ...
@@ -90,7 +92,7 @@ changes can be made to any Symfony 3.4 or higher app:
9092
.. _`public/index.php`: https://github.com/symfony/recipes/blob/master/symfony/framework-bundle/3.3/public/index.php
9193
.. _`index.php diff`: https://github.com/symfony/recipes/compare/8a4e5555e30d5dff64275e2788a901f31a214e79...f54d6a468405d0d8d27b0e790dc09a01e337777a#diff-473fca613b5bda15d87731036cb31586
9294
.. _`bin/console`: https://github.com/symfony/recipes/blob/master/symfony/console/3.3/bin/console
93-
.. _`bin/console diff`: https://github.com/symfony/recipes/compare/8a4e5555e30d5dff64275e2788a901f31a214e79...f54d6a468405d0d8d27b0e790dc09a01e337777a#diff-2af50efd729ff8e61dcbd936cf2b114b
9495
.. _`comment on the top of .env`: https://github.com/symfony/recipes/blob/master/symfony/flex/1.0/.env
9596
.. _`create a new .env.test`: https://github.com/symfony/recipes/blob/master/symfony/phpunit-bridge/3.3/.env.test
9697
.. _`phpunit.xml.dist file`: https://github.com/symfony/recipes/blob/master/symfony/phpunit-bridge/3.3/phpunit.xml.dist
98+
.. _`One further change to the recipe in January 2019`: https://github.com/symfony/recipes/pull/501

contributing/code/security.rst

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,78 @@ of the downstream projects included in this process:
9191
* Drupal (releases typically happen on Wednesdays)
9292
* eZPublish
9393

94+
Issue Severity
95+
--------------
96+
97+
In order to determine the severity of a security issue we take into account
98+
the complexity of any potential attack, the impact of the vulnerability and
99+
also how many projects it is likely to affect. This score out of 15 is then
100+
converted into a level of: Low, Medium, High, Critical, or Exceptional.
101+
102+
Attack Complexity
103+
~~~~~~~~~~~~~~~~~
104+
105+
*Score of between 1 and 5 depending on how complex it is to exploit the
106+
vulnerability*
107+
108+
* 4 - 5 Basic: attacker must follow a set of simple steps
109+
* 2 - 3 Complex: attacker must follow non-intuitive steps with a high level
110+
of dependencies
111+
* 1 - 2 High: A successful attack depends on conditions beyond the attacker's
112+
control. That is, a successful attack cannot be accomplished at will, but
113+
requires the attacker to invest in some measurable amount of effort in
114+
preparation or execution against the vulnerable component before a successful
115+
attack can be expected.
116+
117+
Impact
118+
~~~~~~
119+
120+
*Scores from the following areas are added together to produce a score. The
121+
score for Impact is capped at 6. Each area is scored between 0 and 4.*
122+
123+
* Integrity: Does this vulnerability cause non-public data to be accessible?
124+
If so, does the attacker have control over the data disclosed? (0-4)
125+
* Disclosure: Can this exploit allow system data (or data handled by the
126+
system) to be compromised? If so, does the attacker have control over
127+
modification? (0-4)
128+
* Code Execution: Does the vulnerability allow arbitrary code to be executed
129+
on an end-users system, or the server that it runs on? (0-4)
130+
* Availability: Is the availability of a service or application affected? Is
131+
it reduced availability or total loss of availability of a service /
132+
application? Availability includes networked services (e.g., databases) or
133+
resources such as consumption of network bandwidth, processor cycles, or
134+
disk space. (0-4)
135+
136+
Affected Projects
137+
~~~~~~~~~~~~~~~~~
138+
139+
*Scores from the following areas are added together to produce a score. The
140+
score for Affected Projects is capped at 4.*
141+
142+
* Will it affect some or all using a component? (1-2)
143+
* Is the usage of the component that would cause such a thing already
144+
considered bad practice? (0-1)
145+
* How common/popular is the component (e.g. Console vs HttpFoundation vs
146+
Lock)? (0-2)
147+
* Are a number of well-known open source projects using Symfony affected
148+
that requires coordinated releases? (0-1)
149+
150+
Score Totals
151+
~~~~~~~~~~~~
152+
153+
* Attack Complexity: 1 - 4
154+
* Impact: 1 - 6
155+
* Affected Projects: 1 - 4
156+
157+
Severity levels
158+
~~~~~~~~~~~~~~~
159+
160+
* Low: 1 - 5
161+
* Medium: 6 - 10
162+
* High: 11 - 12
163+
* Critical: 13 - 14
164+
* Exceptional: 15
165+
94166
Security Advisories
95167
-------------------
96168

controller.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ and ``redirect()`` methods::
148148
// redirect to a route with parameters
149149
return $this->redirectToRoute('app_lucky_number', array('max' => 10));
150150

151-
// redirects to a route and mantains the original query string parameters
151+
// redirects to a route and maintains the original query string parameters
152152
return $this->redirectToRoute('blog_show', $request->query->all());
153153

154154
// redirects externally

doctrine/pdo_session_storage.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ To use it, first register a new handler service:
2323
2424
Symfony\Component\HttpFoundation\Session\Storage\Handler\PdoSessionHandler:
2525
arguments:
26-
- 'mysql:dbname=mydatabase, host=myhost'
26+
- 'mysql:dbname=mydatabase; host=myhost; port=myport'
2727
- { db_username: myuser, db_password: mypassword }
2828
2929
# If you're using Doctrine & want to re-use that connection, then:
@@ -61,7 +61,7 @@ To use it, first register a new handler service:
6161
6262
$storageDefinition = $container->autowire(PdoSessionHandler::class)
6363
->setArguments(array(
64-
'mysql:dbname=mydatabase, host=myhost',
64+
'mysql:dbname=mydatabase; host=myhost; port=myport',
6565
array('db_username' => 'myuser', 'db_password' => 'mypassword'),
6666
))
6767
;
@@ -123,7 +123,7 @@ a second array argument to ``PdoSessionHandler``:
123123
124124
Symfony\Component\HttpFoundation\Session\Storage\Handler\PdoSessionHandler:
125125
arguments:
126-
- 'mysql:dbname=mydatabase, host=myhost'
126+
- 'mysql:dbname=mydatabase; host=myhost; port=myport'
127127
- { db_table: 'sessions', db_username: 'myuser', db_password: 'mypassword' }
128128
129129
.. code-block:: xml
@@ -156,7 +156,7 @@ a second array argument to ``PdoSessionHandler``:
156156
157157
$container->autowire(PdoSessionHandler::class)
158158
->setArguments(array(
159-
'mysql:dbname=mydatabase, host=myhost',
159+
'mysql:dbname=mydatabase; host=myhost; port=myport',
160160
array('db_table' => 'sessions', 'db_username' => 'myuser', 'db_password' => 'mypassword')
161161
))
162162
;

doctrine/registration_form.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ saves the user::
152152
public function register(Request $request, UserPasswordEncoderInterface $passwordEncoder): Response
153153
{
154154
$user = new User();
155-
$form = $this->createForm(RegistrationFormType::class);
155+
$form = $this->createForm(RegistrationFormType::class, $user);
156156
$form->handleRequest($request);
157157

158158
if ($form->isSubmitted() && $form->isValid()) {

doctrine/reverse_engineering.rst

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,23 @@ files: ``BlogPost.php`` and ``BlogComment.php``.
7070
7171
$ php bin/console doctrine:mapping:import 'App\Entity' xml --path=config/doctrine
7272
73+
In this case, make sure to adapt your mapping configuration accordingly:
74+
75+
.. code-block:: yaml
76+
77+
# config/packages/doctrine.yaml
78+
doctrine:
79+
# ...
80+
orm:
81+
# ...
82+
mappings:
83+
App:
84+
is_bundle: false
85+
type: yml # Set to xml in case of XML mapping
86+
dir: '%kernel.project_dir%/config/doctrine'
87+
prefix: 'App\Entity'
88+
alias: App
89+
7390
Generating the Getters & Setters or PHP Classes
7491
-----------------------------------------------
7592

frontend/encore/copy-files.rst

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ files into your final output directory.
4444
+ // optional target path, relative to the output dir
4545
+ //to: 'images/[path][name].[ext]',
4646
+
47+
+ // if versioning is enabled, add the file hash too
48+
+ //to: 'images/[path][name].[hash:8].[ext]',
49+
+
4750
+ // only copy files matching this pattern
4851
+ //pattern: /\.(png|jpg|jpeg)$/
4952
+ })
@@ -57,10 +60,10 @@ To render inside Twig, use the ``asset()`` function:
5760
.. code-block:: html+twig
5861

5962
{# assets/images/logo.png was copied to public/build/logo.png #}
60-
<img src="{{ asset('build/logo.png') }}"
63+
<img src="{{ asset('build/logo.png') }}">
6164

6265
{# assets/images/subdir/logo.png was copied to public/build/subdir/logo.png #}
63-
<img src="{{ asset('build/subdir/logo.png') }}"
66+
<img src="{{ asset('build/subdir/logo.png') }}">
6467

6568
Make sure you've enabled the :ref:`json_manifest_path <load-manifest-files>` option,
6669
which tells the ``asset()`` function to read the final paths from the ``manifest.json``

introduction/from_flat_php_to_symfony2.rst

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ of the application are isolated in a new file called ``model.php``::
181181
in this example, only a portion (or none) of the model is actually concerned
182182
with accessing a database.
183183

184-
The controller (``index.php``) is now is just a few lines of code::
184+
The controller (``index.php``) is now just a few lines of code::
185185

186186
// index.php
187187
require_once 'model.php';
@@ -262,7 +262,7 @@ an individual blog result based on a given id::
262262
{
263263
$connection = open_database_connection();
264264

265-
$query = 'SELECT created_at, title, body FROM post WHERE id=:id';
265+
$query = 'SELECT created_at, title, body FROM post WHERE id=:id';
266266
$statement = $connection->prepare($query);
267267
$statement->bindValue(':id', $id, PDO::PARAM_INT);
268268
$statement->execute();
@@ -533,7 +533,7 @@ a simple application. Along the way, you've made a simple routing
533533
system and a method using ``ob_start()`` and ``ob_get_clean()`` to render
534534
templates. If, for some reason, you needed to continue building this "framework"
535535
from scratch, you could at least use Symfony's standalone
536-
:doc:`Routing </components/routing>` and component and :doc:`Twig </templating>`,
536+
:doc:`Routing </components/routing>` component and :doc:`Twig </templating>`,
537537
which already solve these problems.
538538

539539
Instead of re-solving common problems, you can let Symfony take care of
@@ -664,9 +664,9 @@ object are sent back to the client.
664664

665665
It's a beautiful thing.
666666

667-
.. figure:: /_images/http/request-flow.png
668-
:align: center
669-
:alt: Symfony request flow
667+
.. raw:: html
668+
669+
<object data="../_images/http/request-flow.svg" type="image/svg+xml"></object>
670670

671671
Where Symfony Delivers
672672
----------------------

introduction/http_fundamentals.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -361,12 +361,12 @@ to do:
361361

362362
.. _request-flow-figure:
363363

364-
.. figure:: /_images/http/request-flow.png
365-
:align: center
366-
:alt: Symfony request flow
364+
.. raw:: html
365+
366+
<object data="../_images/http/request-flow.svg" type="image/svg+xml"></object>
367367

368-
Incoming requests are interpreted by the :doc:`Routing component </routing>` and
369-
passed to PHP functions that return ``Response`` objects.
368+
Incoming requests are interpreted by the :doc:`Routing component </routing>` and
369+
passed to PHP functions that return ``Response`` objects.
370370

371371
This may not make sense yet, but as you keep reading, you'll learn about :doc:`routes </routing>`
372372
and :doc:`controllers </controller>`: the two fundamental parts to creating a page.

profiler/wdt_follow_ajax.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ Ideally this header should only be set during development and not for
2121
production. This can be accomplished by setting the header in a
2222
:ref:`kernel.response <component-http-kernel-kernel-response>` event listener::
2323

24+
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
25+
26+
// ...
27+
2428
public function onKernelResponse(FilterResponseEvent $event)
2529
{
2630
$response = $event->getResponse();

quick_tour/the_architecture.rst

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -288,9 +288,8 @@ as *environment* variables. This means that Symfony works *perfectly* with
288288
Platform as a Service (PaaS) deployment systems as well as Docker.
289289

290290
But setting environment variables while developing can be a pain. That's why your
291-
app automatically loads a ``.env`` file, if the ``APP_ENV`` environment variable
292-
isn't set in the environment. The keys in this file then become environment variables
293-
and are read by your app:
291+
app automatically loads a ``.env`` file. The keys in this file then become environment
292+
variables and are read by your app:
294293

295294
.. code-block:: bash
296295

reference/constraints/IdenticalTo.rst

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ Basic Usage
3030
The following constraints ensure that:
3131

3232
* ``firstName`` of ``Person`` class is equal to ``Mary`` *and* is a string
33-
* ``age`` is equal to``20`` *and* is of type integer
33+
* ``age`` is equal to ``20`` *and* is of type integer
3434

3535
.. configuration-block::
3636

@@ -61,6 +61,8 @@ The following constraints ensure that:
6161
# config/validator/validation.yaml
6262
App\Entity\Person:
6363
properties:
64+
firstName:
65+
- IdenticalTo: Mary
6466
age:
6567
- IdenticalTo:
6668
value: 20
@@ -74,6 +76,11 @@ The following constraints ensure that:
7476
xsi:schemaLocation="http://symfony.com/schema/dic/constraint-mapping http://symfony.com/schema/dic/constraint-mapping/constraint-mapping-1.0.xsd">
7577
7678
<class name="App\Entity\Person">
79+
<property name="firstName">
80+
<constraint name="IdenticalTo">
81+
<value>Mary</value>
82+
</constraint>
83+
</property>
7784
<property name="age">
7885
<constraint name="IdenticalTo">
7986
<option name="value">20</option>
@@ -94,6 +101,8 @@ The following constraints ensure that:
94101
{
95102
public static function loadValidatorMetadata(ClassMetadata $metadata)
96103
{
104+
$metadata->addPropertyConstraint('firstName', new Assert\IdenticalTo('Mary'));
105+
97106
$metadata->addPropertyConstraint('age', new Assert\IdenticalTo(array(
98107
'value' => 20,
99108
)));

0 commit comments

Comments
 (0)
0