Skip to content

Commit 4f90e0e

Browse files
committed
Merge branch '4.2'
* 4.2: [OptionsResolver] Updated some example code to use modern PHP Fixed the highlighting of some form Twig code examples Replace Controller with AbstractController [#10995] fix some minor typos [Diversity] Reword Diversity Guidance Team Language
2 parents c63bd46 + 89bc2db commit 4f90e0e

File tree

10 files changed

+72
-84
lines changed

10 files changed

+72
-84
lines changed

components/options_resolver.rst

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ Imagine you have a ``Mailer`` class which has four options: ``host``,
3636
}
3737
}
3838

39-
When accessing the ``$options``, you need to add a lot of boilerplate code to
39+
When accessing the ``$options``, you need to add some boilerplate code to
4040
check which options are set::
4141

4242
class Mailer
@@ -46,29 +46,17 @@ check which options are set::
4646
{
4747
$mail = ...;
4848

49-
$mail->setHost(isset($this->options['host'])
50-
? $this->options['host']
51-
: 'smtp.example.org');
52-
53-
$mail->setUsername(isset($this->options['username'])
54-
? $this->options['username']
55-
: 'user');
56-
57-
$mail->setPassword(isset($this->options['password'])
58-
? $this->options['password']
59-
: 'pa$$word');
60-
61-
$mail->setPort(isset($this->options['port'])
62-
? $this->options['port']
63-
: 25);
49+
$mail->setHost($this->options['host'] ?? 'smtp.example.org');
50+
$mail->setUsername($this->options['username'] ?? 'user');
51+
$mail->setPassword($this->options['password'] ?? 'pa$$word');
52+
$mail->setPort($this->options['port'] ?? 25);
6453

6554
// ...
6655
}
6756
}
6857

69-
This boilerplate is hard to read and repetitive. Also, the default values of the
70-
options are buried in the business logic of your code. Use the
71-
:phpfunction:`array_replace` to fix that::
58+
Also, the default values of the options are buried in the business logic of your
59+
code. Use the :phpfunction:`array_replace` to fix that::
7260

7361
class Mailer
7462
{

contributing/diversity/governance.rst

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ Guidance
1313
--------
1414

1515
The project leader, Fabien Potencier, is responsible for publicly appointing
16-
five (5) key players of the initiative to provide guidance and drive it forward,
17-
but also retains the right to revoke any of the key players at any time. These
18-
guiding key players should:
16+
five (5) members of the initiative to provide guidance and drive it forward,
17+
but also retains the right to revoke any of the appointed members at any time.
18+
This guidance team should:
1919

2020
* Be committed to the initiative's cause and have joined because they want to
2121
help the initiative to deliver its purpose most effectively for the
@@ -37,17 +37,17 @@ Veto
3737
~~~~
3838

3939
The project leader (Fabien Potencier) will have the right to veto any actionable
40-
item, regardless of the vote of the initiative's key players. The project leader
41-
may, at their discretion, also appoint other people from among the initiative's
42-
key players to also have the right to veto - in such a case these people are
43-
expected to use appropriate judgement to know when to use a "no" vote or a veto.
44-
Any single veto will reject an actionable item.
40+
item, regardless of the vote of the initiative's guidance team. The project
41+
leader may, at their discretion, also appoint other people from among the
42+
initiative's guidance team to also have the right to veto - in such a case these
43+
people are expected to use appropriate judgement to know when to use a "no" vote
44+
or a veto. Any single veto will reject an actionable item.
4545

4646
The purpose of having members with the right to veto is to prevent a "people's
4747
majority" from overruling the core interests of the Symfony project. This will
48-
encourage communication between proposing members, the initiative's key players
49-
and the Core Team to create realistic proposals, and in return any veto will
50-
come with a full explanation (not just a justification).
48+
encourage communication between proposing members, the initiative's guidance
49+
team and the Core Team to create realistic proposals, and in return any veto
50+
will come with a full explanation (not just a justification).
5151

5252
Advice Process
5353
~~~~~~~~~~~~~~
@@ -57,67 +57,67 @@ the community (advice, general consensus, or non-binding poll) should be
5757
requested from the wider community - this will aim to include both those who
5858
will be meaningfully affected and those with meaningful expertise in the matter
5959
at hand.
60-
This feedback will enable the key players to have the confidence to vote for the
61-
best possible decision according to the information they have available, knowing
62-
that the responsibility they accept for said vote is justified.
60+
This feedback will enable the guidance team to have the confidence to vote for
61+
the best possible decision according to the information they have available,
62+
knowing that the responsibility they accept for said vote is justified.
6363

6464
Voting
6565
~~~~~~
6666

67-
Key players have the right to vote on proposals for actionable items.
67+
The guidance team have the right to vote on proposals for actionable items.
6868
The quorum of "yes" or "no" votes required for a decision to be considered valid
69-
is at least 75% of active, appointed key players - to abstain from voting means
70-
that vote will not be counted towards the quorum.
71-
For an actionable item to pass, approval from greater than 50% of the voting key
72-
players is required. Use or management of finances/donations require at least a
73-
two-thirds majority to pass.
69+
is at least 75% of active, appointed members of the guidance team - to abstain
70+
from voting means that vote will not be counted towards the quorum.
71+
For an actionable item to pass, approval from greater than 50% of the voting
72+
guidance team members is required. Use or management of finances/donations
73+
require at least a two-thirds majority to pass.
7474

7575
Guidance Principles
7676
-------------------
7777

7878
Purpose
7979
~~~~~~~
8080

81-
The initiative should be led by an effective team of key players that provide
81+
The initiative should be led by an effective guidance team that provides
8282
strategic guidance in line with the initiative's aims and values, including a
83-
shared understanding with fellow key players to ensure that these are being
84-
delivered effectively and sustainably.
83+
shared understanding with fellow initiative members to ensure that these are
84+
being delivered effectively and sustainably.
8585

8686
Integrity
8787
~~~~~~~~~
8888

89-
Key players should act with integrity: adopting values which help achieve the
90-
initiative's purposes, even where difficult or unpopular decisions are required.
91-
Key players should undertake their duties, aware of the importance of confidence
92-
and trust in the initiative from the wider community, and ultimately
93-
acknowledges shared responsibility for the reputation of the Symfony project
94-
like the Core Team.
89+
The guidance team should act with integrity: adopting values which help achieve
90+
the initiative's purposes, even where difficult or unpopular decisions are
91+
required. Guidance team members should undertake their duties, aware of the
92+
importance of confidence and trust in the initiative from the wider community,
93+
and ultimately acknowledges shared responsibility for the reputation of the
94+
Symfony project like the Core Team.
9595

9696
Decision-making Effectiveness
9797
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
9898

99-
Key players should work as an effective team, using the appropriate balance of
100-
skills, experience, backgrounds and knowledge to make sure its decision-making
101-
processes are informed and equitable. Risk assessment and management systems
102-
should be set up and monitored.
99+
Guidance members should work as an effective team, using the appropriate balance
100+
of skills, experience, backgrounds and knowledge to make sure its
101+
decision-making processes are informed and equitable. Risk assessment and
102+
management systems should be set up and monitored.
103103

104104
Openness and Accountability
105105
~~~~~~~~~~~~~~~~~~~~~~~~~~~
106106

107-
The behaviour and conduct of the initiative's key players sets the tone for the
108-
rest of the community. Key players should lead by example to create a culture
109-
that enables members to feel it is safe to suggest, question and challenge -
110-
rather than avoid - difficult ideas and topics. Key players guide the initiative
111-
in being transparent, accountable and open.
107+
The behaviour and conduct of the initiative's guidance team sets the tone for
108+
the rest of the community. The guidance team should lead by example to create a
109+
culture that enables members to feel it is safe to suggest, question and
110+
challenge - rather than avoid - difficult ideas and topics. The team should
111+
guide the initiative in being transparent, accountable and open.
112112

113113
Adaptability
114114
~~~~~~~~~~~~
115115

116116
The initiative should establish processes that do not require any one person to
117117
hold specific positions while being adaptable to accommodate unforeseen needs of
118118
the community, especially as membership and involvement grows over time (changes
119-
to key player appointment will have to be approved by the current system, which
120-
is Fabien Potencier).
119+
to guidance team member appointment will have to be approved by the current
120+
system, which is Fabien Potencier).
121121

122122
.. _`lsmith77`: https://github.com/lsmith77/
123123
.. _`michellesanver`: https://github.com/michellesanver/

doctrine/registration_form.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ The form class for the registration form will look something like this::
9696
new Length([
9797
'min' => 6,
9898
'minMessage' => 'Your password should be at least {{ limit }} characters',
99-
'max' => 4096
99+
'max' => 4096,
100100
]),
101101
],
102102
])
@@ -170,7 +170,7 @@ saves the user::
170170

171171
// do anything else you need here, like send an email
172172

173-
return $this->redirect('app_homepage');
173+
return $this->redirectToRoute('app_homepage');
174174
}
175175

176176
return $this->render('registration/register.html.twig', [
@@ -223,13 +223,13 @@ To do this, add a ``termsAccepted`` field to your form, but set its
223223
public function buildForm(FormBuilderInterface $builder, array $options)
224224
{
225225
$builder
226-
->add('email', EmailType::class);
226+
->add('email', EmailType::class)
227227
// ...
228228
->add('termsAccepted', CheckboxType::class, [
229229
'mapped' => false,
230230
'constraints' => new IsTrue(),
231231
])
232-
);
232+
;
233233
}
234234
}
235235

form/action_method.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ options:
117117
Finally, you can override the action and method in the template by passing them
118118
to the ``form()`` or the ``form_start()`` helper functions:
119119

120-
.. code-block:: html+twig
120+
.. code-block:: twig
121121
122122
{# templates/default/new.html.twig #}
123123
{{ form_start(form, {'action': path('target_route'), 'method': 'GET'}) }}

form/bootstrap4.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ Bootstrap 4 has a feature called "`custom forms`_". You can enable that on your
9595
Symfony Form ``RadioType`` and ``CheckboxType`` by adding a class called ``radio-custom``
9696
and ``checkbox-custom`` respectively.
9797

98-
.. code-block:: html+twig
98+
.. code-block:: twig
9999
100100
{{ form_row(form.myRadio, {label_attr: {class: 'radio-custom'} }) }}
101101
{{ form_row(form.myCheckbox, {label_attr: {class: 'checkbox-custom'} }) }}

form/form_collections.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ new "tag" forms. To render it, make the following change to your template:
295295
on it. You could even choose to render only one of its fields (e.g. the
296296
``name`` field):
297297

298-
.. code-block:: html+twig
298+
.. code-block:: twig
299299
300300
{{ form_widget(form.tags.vars.prototype.name)|e }}
301301

form/form_customization.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ Some of the Twig functions mentioned in the previous section allow to pass
8686
variables to configure their behavior. For example, the ``form_label()``
8787
function lets you define a custom label to override the one defined in the form:
8888

89-
.. code-block:: html+twig
89+
.. code-block:: twig
9090
9191
{{ form_label(form.task, 'My Custom Task Label') }}
9292
@@ -96,7 +96,7 @@ type, but one common option is ``attr``, which allows you to modify HTML
9696
attributes on the form element. The following would add the ``task_field`` CSS
9797
class to the rendered input text field:
9898

99-
.. code-block:: html+twig
99+
.. code-block:: twig
100100
101101
{{ form_widget(form.task, {'attr': {'class': 'task_field'}}) }}
102102
@@ -116,7 +116,7 @@ If you need to render form fields "by hand" then you can access individual
116116
values for fields (such as the ``id``, ``name`` and ``label``) using its
117117
``vars`` property. For example to get the ``id``:
118118

119-
.. code-block:: html+twig
119+
.. code-block:: twig
120120
121121
{{ form.task.vars.id }}
122122

form/form_themes.rst

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ Although most of the times you'll apply form themes globally, you may need to
102102
apply a theme only to some specific form. You can do that with the
103103
:ref:`form_theme Twig tag <reference-twig-tag-form-theme>`:
104104

105-
.. code-block:: html+twig
105+
.. code-block:: twig
106106
107107
{# this form theme will be applied only to the form of this template #}
108108
{% form_theme form 'foundation_5_layout.html.twig' %}
@@ -137,7 +137,7 @@ Applying Different Themes to Child Forms
137137

138138
You can also apply a form theme to a specific child of your form:
139139

140-
.. code-block:: html+twig
140+
.. code-block:: twig
141141
142142
{% form_theme form.a_child_form 'form/my_custom_theme.html.twig' %}
143143
@@ -161,7 +161,7 @@ can be installed on different Symfony apps (and so you can't control what themes
161161
are enabled globally). To do that, add the ``only`` keyword after the list of
162162
form themes:
163163

164-
.. code-block:: html+twig
164+
.. code-block:: twig
165165
166166
{% form_theme form with ['foundation_5_layout.html.twig'] only %}
167167
@@ -175,7 +175,7 @@ form themes:
175175
yourself, or extend one of the built-in form themes with Twig's ``use``
176176
keyword instead of ``extends`` to re-use the original theme contents.
177177

178-
.. code-block:: html+twig
178+
.. code-block:: twig
179179
180180
{# templates/form/common.html.twig #}
181181
{% use "form_div_layout.html.twig" %}
@@ -192,7 +192,7 @@ with one or more of those blocks that you want to use when rendering a form.
192192
Consider for example a form field that represents an integer property called
193193
``age``. If you add this to the template:
194194

195-
.. code-block:: html+twig
195+
.. code-block:: twig
196196
197197
{{ form_widget(form.age) }}
198198
@@ -377,7 +377,7 @@ rules to know which Twig blocks to define.
377377
For example, if your form theme is simple and you only want to override the
378378
``<input type="integer">`` elements, create this template:
379379

380-
.. code-block:: html+twig
380+
.. code-block:: twig
381381
382382
{# templates/form/my_theme.html.twig #}
383383
{% block integer_widget %}
@@ -429,7 +429,7 @@ you want to apply the theme globally to all forms, define the
429429
430430
If you only want to apply it to some specific forms, use the ``form_theme`` tag:
431431

432-
.. code-block:: html+twig
432+
.. code-block:: twig
433433
434434
{% form_theme form 'form/my_theme.html.twig' %}
435435
@@ -453,7 +453,7 @@ built-in themes using the `Twig "use" tag`_ instead of the ``extends`` tag so
453453
you can inherit all its blocks (if you are unsure, extend from the default
454454
``form_div_layout.html.twig`` theme):
455455

456-
.. code-block:: html+twig
456+
.. code-block:: twig
457457
458458
{# templates/form/my_theme.html.twig #}
459459
{% use 'form_div_layout.html.twig' %}

security/user_provider.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,8 @@ to retrieve them:
109109
]);
110110
111111
The ``providers`` section creates a "user provider" called ``users`` that knows
112-
to query from your ``App\Entity\User`` entity by the ``username`` property. You
113-
can choose any name for the user provider, but it's recommended to pick a
112+
how to query from your ``App\Entity\User`` entity by the ``username`` property.
113+
You can choose any name for the user provider, but it's recommended to pick a
114114
descriptive name because this will be later used in the firewall configuration.
115115

116116
.. _authenticating-someone-with-a-custom-entity-provider:
@@ -208,7 +208,7 @@ Memory User Provider
208208
--------------------
209209

210210
It's not recommended to use this provider in real applications because of its
211-
limitations and how difficult is to manage users. It may be useful in app
211+
limitations and how difficult it is to manage users. It may be useful in app
212212
prototypes and for limited apps that don't store users in databases.
213213

214214
This user provider stores all user information in a configuration file,

service_container.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -534,11 +534,11 @@ You can also fetch parameters directly from the container::
534534
{
535535
// ...
536536

537-
// this ONLY works if you extend the base Controller
538-
$adminEmail = $this->container->getParameter('admin_email');
537+
// this shortcut ONLY works if you extend the base AbstractController
538+
$adminEmail = $this->getParameter('admin_email');
539539

540-
// or a shorter way!
541-
// $adminEmail = $this->getParameter('admin_email');
540+
// this is the equivalent code of the previous shortcut:
541+
// $adminEmail = $this->container->get('parameter_bag')->get('admin_email');
542542
}
543543

544544
For more info about parameters, see :doc:`/service_container/parameters`.

0 commit comments

Comments
 (0)