Skip to content

Commit 35ae50c

Browse files
committed
Merge branch '2.8'
* 2.8: Finding more old form references Remove note about request service, which is not used anymore Remove information about request scpoe
2 parents 7bb2785 + 4ad3bce commit 35ae50c

File tree

11 files changed

+15
-88
lines changed

11 files changed

+15
-88
lines changed

best_practices/forms.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ You can also
6767
:ref:`register your form type as a service <form-cookbook-form-field-service>`.
6868
But this is *not* recommended unless you plan to reuse the new form type in many
6969
places or embed it in other forms directly or via the
70-
:doc:`collection type </reference/forms/types/collection>`.
70+
:doc:`CollectionType </reference/forms/types/collection>`.
7171

7272
For most forms that are used only to edit or create something, registering
7373
the form as a service is over-kill, and makes it more difficult to figure

book/forms.rst

+3-3
Original file line numberDiff line numberDiff line change
@@ -678,7 +678,7 @@ Field Type Options
678678

679679
Each field type has a number of options that can be used to configure it.
680680
For example, the ``dueDate`` field is currently being rendered as 3 select
681-
boxes. However, the :doc:`date field </reference/forms/types/date>` can be
681+
boxes. However, the :doc:`DateType </reference/forms/types/date>` can be
682682
configured to be rendered as a single text box (where the user would enter
683683
the date as a string in the box)::
684684

@@ -1430,7 +1430,7 @@ form with many ``Product`` sub-forms). This is done by using the ``collection``
14301430
field type.
14311431

14321432
For more information see the ":doc:`/cookbook/form/form_collections`" cookbook
1433-
entry and the :doc:`collection </reference/forms/types/collection>` field type reference.
1433+
entry and the :doc:`CollectionType </reference/forms/types/collection>` reference.
14341434

14351435
.. index::
14361436
single: Forms; Theming
@@ -1964,7 +1964,7 @@ Learn more from the Cookbook
19641964
----------------------------
19651965

19661966
* :doc:`/cookbook/doctrine/file_uploads`
1967-
* :doc:`File Field Reference </reference/forms/types/file>`
1967+
* :doc:`FileType Reference </reference/forms/types/file>`
19681968
* :doc:`Creating Custom Field Types </cookbook/form/create_custom_field_type>`
19691969
* :doc:`/cookbook/form/form_customization`
19701970
* :doc:`/cookbook/form/dynamic_form_modification`

cookbook/console/console_command.rst

-63
Original file line numberDiff line numberDiff line change
@@ -101,69 +101,6 @@ service container. In other words, you have access to any configured service::
101101
// ...
102102
}
103103

104-
However, due to the :doc:`container scopes </cookbook/service_container/scopes>` this
105-
code doesn't work for some services. For instance, if you try to get the ``request``
106-
service or any other service related to it, you'll get the following error:
107-
108-
.. code-block:: text
109-
110-
You cannot create a service ("request") of an inactive scope ("request").
111-
112-
Consider the following example that uses the ``translator`` service to
113-
translate some contents using a console command::
114-
115-
protected function execute(InputInterface $input, OutputInterface $output)
116-
{
117-
$name = $input->getArgument('name');
118-
$translator = $this->getContainer()->get('translator');
119-
if ($name) {
120-
$output->writeln(
121-
$translator->trans('Hello %name%!', array('%name%' => $name))
122-
);
123-
} else {
124-
$output->writeln($translator->trans('Hello!'));
125-
}
126-
}
127-
128-
If you dig into the Translator component classes, you'll see that the ``request``
129-
service is required to get the locale into which the contents are translated::
130-
131-
// vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Translation/Translator.php
132-
public function getLocale()
133-
{
134-
if (null === $this->locale && $this->container->isScopeActive('request')
135-
&& $this->container->has('request')) {
136-
$this->locale = $this->container->get('request')->getLocale();
137-
}
138-
139-
return $this->locale;
140-
}
141-
142-
Therefore, when using the ``translator`` service inside a command, you'll get the
143-
previous *"You cannot create a service of an inactive scope"* error message.
144-
The solution in this case is as easy as setting the locale value explicitly
145-
before translating contents::
146-
147-
protected function execute(InputInterface $input, OutputInterface $output)
148-
{
149-
$name = $input->getArgument('name');
150-
$locale = $input->getArgument('locale');
151-
152-
$translator = $this->getContainer()->get('translator');
153-
$translator->setLocale($locale);
154-
155-
if ($name) {
156-
$output->writeln(
157-
$translator->trans('Hello %name%!', array('%name%' => $name))
158-
);
159-
} else {
160-
$output->writeln($translator->trans('Hello!'));
161-
}
162-
}
163-
164-
However, for other services the solution might be more complex. For more details,
165-
see :doc:`/cookbook/service_container/scopes`.
166-
167104
Invoking other Commands
168105
-----------------------
169106

cookbook/doctrine/file_uploads.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ How to Handle File Uploads with Doctrine
1414
Handling file uploads with Doctrine entities is no different than handling
1515
any other file upload. In other words, you're free to move the file in your
1616
controller after handling a form submission. For examples of how to do this,
17-
see the :doc:`file type reference </reference/forms/types/file>` page.
17+
see the :doc:`FileType reference </reference/forms/types/file>` page.
1818

1919
If you choose to, you can also integrate the file upload into your entity
2020
lifecycle (i.e. creation, update and removal). In this case, as your entity
@@ -98,7 +98,7 @@ file.
9898
.. tip::
9999

100100
If you have not done so already, you should probably read the
101-
:doc:`file </reference/forms/types/file>` type documentation first to
101+
:doc:`FileType </reference/forms/types/file>` documentation first to
102102
understand how the basic upload process works.
103103

104104
.. note::

cookbook/form/data_transformers.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ How to Use Data Transformers
66

77
Data transformers are used to translate the data for a field into a format that can
88
be displayed in a form (and back on submit). They're already used internally for
9-
many field types. For example, the :doc:`date field type </reference/forms/types/date>`
9+
many field types. For example, the :doc:`DateType </reference/forms/types/date>` field
1010
can be rendered as a ``yyyy-MM-dd``-formatted input textbox. Internally, a data transformer
1111
converts the starting ``DateTime`` value of the field into the ``yyyy-MM-dd`` string
1212
to render the form, and then back into a ``DateTime`` object on submit.

cookbook/form/form_collections.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ goal is to allow the tags of a ``Task`` to be modified right inside the task
106106
form itself, create a form for the ``Task`` class.
107107

108108
Notice that you embed a collection of ``TagType`` forms using the
109-
:doc:`collection </reference/forms/types/collection>` field type::
109+
:doc:`CollectionType </reference/forms/types/collection>` field::
110110

111111
// src/AppBundle/Form/Type/TaskType.php
112112
namespace AppBundle\Form\Type;

cookbook/templating/twig_extension.rst

-10
Original file line numberDiff line numberDiff line change
@@ -99,16 +99,6 @@ Now you must let the Service Container know about your newly created Twig Extens
9999
->setPublic(false)
100100
->addTag('twig.extension');
101101
102-
.. note::
103-
104-
Keep in mind that Twig Extensions are not lazily loaded. This means that
105-
there's a higher chance that you'll get a
106-
:class:`Symfony\\Component\\DependencyInjection\\Exception\\ServiceCircularReferenceException`
107-
or a
108-
:class:`Symfony\\Component\\DependencyInjection\\Exception\\ScopeWideningInjectionException`
109-
if any services (or your Twig Extension in this case) are dependent on
110-
the request service. For more information take a look at :doc:`/cookbook/service_container/scopes`.
111-
112102
Using the custom Extension
113103
--------------------------
114104

reference/constraints/File.rst

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ Validates that a value is a valid "file", which can be one of the following:
88
* A valid :class:`Symfony\\Component\\HttpFoundation\\File\\File` object
99
(including objects of class :class:`Symfony\\Component\\HttpFoundation\\File\\UploadedFile`).
1010

11-
This constraint is commonly used in forms with the :doc:`file </reference/forms/types/file>`
12-
form type.
11+
This constraint is commonly used in forms with the :doc:`FileType </reference/forms/types/file>`
12+
form field.
1313

1414
.. tip::
1515

@@ -41,7 +41,7 @@ Basic Usage
4141
-----------
4242

4343
This constraint is most commonly used on a property that will be rendered
44-
in a form as a :doc:`file </reference/forms/types/file>` form type. For
44+
in a form as a :doc:`FileType </reference/forms/types/file>` field. For
4545
example, suppose you're creating an author form where you can upload a "bio"
4646
PDF for the author. In your form, the ``bioFile`` property would be a ``file``
4747
type. The ``Author`` class might look as follows::

reference/constraints/Image.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ Basic Usage
4646
-----------
4747

4848
This constraint is most commonly used on a property that will be rendered
49-
in a form as a :doc:`file </reference/forms/types/file>` form type. For
49+
in a form as a :doc:`FileType </reference/forms/types/file>` field. For
5050
example, suppose you're creating an author form where you can upload a
5151
"headshot" image for the author. In your form, the ``headshot`` property
5252
would be a ``file`` type. The ``Author`` class might look as follows::

reference/forms/types/options/by_reference.rst.inc

+2-2
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ If you set ``by_reference`` to false, submitting looks like this::
4343
So, all that ``by_reference=false`` really does is force the framework to
4444
call the setter on the parent object.
4545

46-
Similarly, if you're using the :doc:`collection</reference/forms/types/collection>`
47-
form type where your underlying collection data is an object (like with
46+
Similarly, if you're using the :doc:`CollectionType </reference/forms/types/collection>`
47+
field where your underlying collection data is an object (like with
4848
Doctrine's ``ArrayCollection``), then ``by_reference`` must be set to ``false``
4949
if you need the adder and remover (e.g. ``addAuthor()`` and ``removeAuthor()``)
5050
to be called.

reference/forms/types/options/invalid_message.rst.inc

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ This is the validation error message that's used if the data entered into
77
this field doesn't make sense (i.e. fails validation).
88

99
This might happen, for example, if the user enters a nonsense string into
10-
a :doc:`time</reference/forms/types/time>` field that cannot be converted
10+
a :doc:`TimeType </reference/forms/types/time>` field that cannot be converted
1111
into a real time or if the user enters a string (e.g. ``apple``) into a
1212
number field.
1313

0 commit comments

Comments
 (0)