8000 Merge branch '2.3' into 2.6 · symfony/symfony-docs@52bd0a9 · GitHub
[go: up one dir, main page]

Skip to content

Commit 52bd0a9

Browse files
committed
Merge branch '2.3' into 2.6
Conflicts: components/event_dispatcher/introduction.rst cookbook/bundles/best_practices.rst reference/forms/types/choice.rst
2 parents 8b8ba03 + 4f3ce84 commit 52bd0a9

28 files changed

+253
-188
lines changed

book/doctrine.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1204,7 +1204,8 @@ to the given ``Category`` object via their ``category_id`` value.
12041204
$category = $product->getCategory();
12051205

12061206
// prints "Proxies\AppBundleEntityCategoryProxy"
1207-
echo get_class($category);
1207+
dump(get_class($category));
1208+
die();
12081209

12091210
This proxy object extends the true ``Category`` object, and looks and
12101211
acts exactly like it. The difference is that, by using a proxy object,

book/service_container.rst

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -276,10 +276,11 @@ The service container is built using a single configuration resource
276276
be imported from inside this file in one way or another. This gives you absolute
277277
flexibility over the services in your application.
278278

279-
External service configuration can be imported in two different ways. The
280-
first - and most common method - is via the ``imports`` directive. Later, you'll
281-
learn about the second method, which is the flexible and preferred method
282-
for importing service configuration from third-party bundles.
279+
External service configuration can be imported in two different ways. The first
280+
method, commonly used to import container configuration from the bundles you've
281+
created - is via the ``imports`` directive. The second method, although slightly more
282+
complex offers more flexibility and is commonly used to import third-party bundle
283+
configuration. Read on to learn more about both methods.
283284

284285
.. index::
285286
single: Service Container; Imports

book/translation.rst

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,13 @@ wrapping each with a function capable of translating the text (or "message")
1212
into the language of the user::
1313

1414
// text will *always* print out in English
15-
echo 'Hello World';
15+
dump('Hello World');
16+
die();
1617

1718
// text can be translated into the end-user's language or
1819
// default to English
19-
echo $translator->trans('Hello World');
20+
dump($translator->trans('Hello World'));
21+
die();
2022

2123
.. note::
2224

components/class_loader/class_map_generator.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ method::
5050

5151
use Symfony\Component\ClassLoader\ClassMapGenerator;
5252

53-
print_r(ClassMapGenerator::createMap(__DIR__.'/library'));
53+
var_dump(ClassMapGenerator::createMap(__DIR__.'/library'));
5454

5555
Given the files and class from the table above, you should see an output like
5656
this:

components/console/console_arguments.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ Have a look at the following command that has three options::
1414

1515
use Symfony\Component\Console\Command\Command;
1616
use Symfony\Component\Console\Input\InputArgument;
17+
use Symfony\Component\Console\Input\InputDefinition;
1718
use Symfony\Component\Console\Input\InputInterface;
1819
use Symfony\Component\Console\Input\InputOption;
1920
use Symfony\Component\Console\Output\OutputInterface;

components/css_selector.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ equivalents::
5151

5252
use Symfony\Component\CssSelector\CssSelector;
5353

54-
print CssSelector::toXPath('div.item > h4 > a');
54+
var_dump(CssSelector::toXPath('div.item > h4 > a'));
5555

5656
This gives the following output:
5757

components/dependency_injection/advanced.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
Advanced Container Configuration
55
================================
66

7+
.. _container-private-services:
8+
79
Marking Services as public / private
810
------------------------------------
911

components/dom_crawler.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ traverse easily::
4747
$crawler = new Crawler($html);
4848

4949
foreach ($crawler as $domElement) {
50-
print $domElement->nodeName;
50+
var_dump($domElement->nodeName);
5151
}
5252

5353
Specialized :class:`Symfony\\Component\\DomCrawler\\Link` and

components/event_dispatcher/generic_event.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ the event arguments::
7575
);
7676
$dispatcher->dispatch('foo', $event);
7777

78-
echo $event['counter'];
78+
var_dump($event['counter']);
7979

8080
class FooListener
8181
{
@@ -96,7 +96,7 @@ Filtering data::
9696
$event = new GenericEvent($subject, array('data' => 'Foo'));
9797
$dispatcher->dispatch('foo', $event);
9898

99-
echo $event['data'];
99+
var_dump($event['data']);
100100

101101
class FooListener
102102
{
@@ -105,3 +105,4 @@ Filtering data::
105105
$event['data'] = strtolower($event['data']);
106106
}
107107
}
108+

components/event_dispatcher/introduction.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -638,7 +638,7 @@ dispatched, are passed as arguments to the listener::
638638
{
639639
public function myEventListener(Event $event, $eventName, EventDispatcherInterface $dispatcher)
640640
{
641-
echo $eventName;
641+
// ... do something with the event name
642642
}
643643
}
644644

components/finder.rst

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,14 @@ directories::
3030
$finder->files()->in(__DIR__);
3131

3232
foreach ($finder as $file) {
33-
// Print the absolute path
34-
print $file->getRealpath()."\n";
33+
// Dump the absolute path
34+
var_dump($file->getRealpath());
3535

36-
// Print the relative path to the file, omitting the filename
37-
print $file->getRelativePath()."\n";
36+
// Dump the relative path to the file, omitting the filename
37+
var_dump($file->getRelativePath());
3838

39-
// Print the relative path to the file
40-
print $file->getRelativePathname()."\n";
39+
// Dump the relative path to the file
40+
var_dump($file->getRelativePathname());
4141
}
4242

4343
The ``$file`` is an instance of :class:`Symfony\\Component\\Finder\\SplFileInfo`
@@ -118,9 +118,7 @@ And it also works with user-defined streams::
118118
$finder = new Finder();
119119
$finder->name('photos*')->size('< 100K')->date('since 1 hour ago');
120120
foreach ($finder->in('s3://bucket-name') as $file) {
121-
// ... do something
122-
123-
print $file->getFilename()."\n";
121+
// ... do something with the file
124122
}
125123

126124
.. note::

components/form/introduction.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -396,9 +396,9 @@ is created from the form factory.
396396
->add('dueDate', 'date')
397397
->getForm();
398398
399-
echo $twig->render('new.html.twig', array(
399+
var_dump($twig->render('new.html.twig', array(
400400
'form' => $form->createView(),
401-
));
401+
)));
402402
403403
.. code-block:: php-symfony
404404

components/http_foundation/introduction.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -449,10 +449,10 @@ represented by a PHP callable instead of a string::
449449

450450
$response = new StreamedResponse();
451451
$response->setCallback(function () {
452-
echo 'Hello World';
452+
var_dump('Hello World');
453453
flush();
454454
sleep(2);
455-
echo 'Hello World';
455+
var_dump('Hello World');
456456
flush();
457457
});
458458
$response->send();

components/http_foundation/session_configuration.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -274,18 +274,18 @@ further creates an extension point from where custom logic can be added that
274274
works independently of which handler is being wrapped inside.
275275

276276
There are two kinds of save handler class proxies which inherit from
277-
:class:`Symfony\\Component\\HttpFoundation\\Session\\Storage\\Handler\\AbstractProxy`:
278-
they are :class:`Symfony\\Component\\HttpFoundation\\Session\\Storage\\Handler\\NativeProxy`
279-
and :class:`Symfony\\Component\\HttpFoundation\\Session\\Storage\\Handler\\SessionHandlerProxy`.
277+
:class:`Symfony\\Component\\HttpFoundation\\Session\\Storage\\Proxy\\AbstractProxy`:
278+
they are :class:`Symfony\\Component\\HttpFoundation\\Session\\Storage\\Proxy\\NativeProxy`
279+
and :class:`Symfony\\Component\\HttpFoundation\\Session\\Storage\\Proxy\\SessionHandlerProxy`.
280280

281281
:class:`Symfony\\Component\\HttpFoundation\\Session\\Storage\\NativeSessionStorage`
282282
automatically injects storage handlers into a save handler proxy unless already
283283
wrapped by one.
284284

285-
:class:`Symfony\\Component\\HttpFoundation\\Session\\Storage\\Handler\\NativeProxy`
285+
:class:`Symfony\\Component\\HttpFoundation\\Session\\Storage\\Proxy\\NativeProxy`
286286
is used automatically under PHP 5.3 when internal PHP save handlers are specified
287287
using the ``Native*SessionHandler`` classes, while
288-
:class:`Symfony\\Component\\HttpFoundation\\Session\\Storage\\Handler\\SessionHandlerProxy`
288+
:class:`Symfony\\Component\\HttpFoundation\\Session\\Storage\\Proxy\\SessionHandlerProxy`
289289
will be used to wrap any custom save handlers, that implement :phpclass:`SessionHandlerInterface`.
290290

291291
From PHP 5.4 and above, all session handlers implement :phpclass:`SessionHandlerInterface`

components/intl.rst

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ This class currently only works with the `intl extension`_ installed::
138138
$reader = new BinaryBundleReader();
139139
$data = $reader->read('/path/to/bundle', 'en');
140140

141-
echo $data['Data']['entry1'];
141+
var_dump($data['Data']['entry1']);
142142

143143
PhpBundleReader
144144
~~~~~~~~~~~~~~~
@@ -152,7 +152,7 @@ object::
152152
$reader = new PhpBundleReader();
153153
$data = $reader->read('/path/to/bundle', 'en');
154154

155-
echo $data['Data']['entry1'];
155+
var_dump($data['Data']['entry1']);
156156

157157
BufferedBundleReader
158158
~~~~~~~~~~~~~~~~~~~~
@@ -193,10 +193,10 @@ returned::
193193
$data = $reader->read('/path/to/bundle', 'en');
194194

195195
// Produces an error if the key "Data" does not exist
196-
echo $data['Data']['entry1'];
196+
var_dump($data['Data']['entry1']);
197197

198198
// Returns null if the key "Data" does not exist
199-
echo $reader->readEntry('/path/to/bundle', 'en', array('Data', 'entry1'));
199+
var_dump($reader->readEntry('/path/to/bundle', 'en', array('Data', 'entry1')));
200200

201201
Additionally, the
202202
:method:`Symfony\\Component\\Intl\\ResourceBundle\\Reader\\StructuredBundleReaderInterface::readEntry`
@@ -207,12 +207,12 @@ multi-valued entries (arrays), the values of the more specific and the fallback
207207
locale will be merged. In order to suppress this behavior, the last parameter
208208
``$fallback`` can be set to ``false``::
209209

210-
echo $reader->readEntry(
210+
var_dump($reader->readEntry(
211211
'/path/to/bundle',
212212
'en',
213213
array('Data', 'entry1'),
214214
false
215-
);
215+
));
216216

217217
Accessing ICU Data
218218
------------------

components/property_access/introduction.rst

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ method. This is done using the index notation that is used in PHP::
4747
'first_name' => 'Wouter',
4848
);
4949

50-
echo $accessor->getValue($person, '[first_name]'); // 'Wouter'
51-
echo $accessor->getValue($person, '[age]'); // null
50+
var_dump($accessor->getValue($person, '[first_name]')); // 'Wouter'
51+
var_dump($accessor->getValue($person, '[age]')); // null
5252

5353
As you can see, the method will return ``null`` if the index does not exists.
5454

@@ -64,8 +64,8 @@ You can also use multi dimensional arrays::
6464
)
6565
);
6666

67-
echo $accessor->getValue($persons, '[0][first_name]'); // 'Wouter'
68-
echo $accessor->getValue($persons, '[1][first_name]'); // 'Ryan'
67+
var_dump($accessor->getValue($persons, '[0][first_name]')); // 'Wouter'
68+
var_dump($accessor->getValue($persons, '[1][first_name]')); // 'Ryan'
6969

7070
Reading from Objects
7171
--------------------
@@ -82,13 +82,13 @@ To read from properties, use the "dot" notation::
8282
$person = new Person();
8383
$person->firstName = 'Wouter';
8484

85-
echo $accessor->getValue($person, 'firstName'); // 'Wouter'
85+
var_dump($accessor->getValue($person, 'firstName')); // 'Wouter'
8686

8787
$child = new Person();
8888
$child->firstName = 'Bar';
8989
$person->children = array($child);
9090

91-
echo $accessor->getValue($person, 'children[0].firstName'); // 'Bar'
91+
var_dump($accessor->getValue($person, 'children[0].firstName')); // 'Bar'
9292

9393
.. caution::
9494

@@ -118,7 +118,7 @@ property name (``first_name`` becomes ``FirstName``) and prefixes it with
118118

119119
$person = new Person();
120120

121-
echo $accessor->getValue($person, 'first_name'); // 'Wouter'
121+
var_dump($accessor->getValue($person, 'first_name')); // 'Wouter'
122122

123123
Using Hassers/Issers
124124
~~~~~~~~~~~~~~~~~~~~
@@ -147,10 +147,10 @@ getters, this means that you can do something like this::
147147
$person = new Person();
148148

149149
if ($accessor->getValue($person, 'author')) {
150-
echo 'He is an author';
150+
var_dump('He is an author');
151151
}
152152
if ($accessor->getValue($person, 'children')) {
153-
echo 'He has children';
153+
var_dump('He has children');
154154
}
155155

156156
This will produce: ``He is an author``
@@ -175,7 +175,7 @@ The ``getValue`` method can also use the magic ``__get`` method::
175175

176176
$person = new Person();
177177

178-
echo $accessor->getValue($person, 'Wouter'); // array(...)
178+
var_dump($accessor->getValue($person, 'Wouter')); // array(...)
179179

180180
.. _components-property-access-magic-call:
181181

@@ -213,15 +213,15 @@ enable this feature by using :class:`Symfony\\Component\\PropertyAccess\\Propert
213213
->enableMagicCall()
214214
->getPropertyAccessor();
215215

216-
echo $accessor->getValue($person, 'wouter'); // array(...)
216+
var_dump($accessor->getValue($person, 'wouter')); // array(...)
217217

218218
.. versionadded:: 2.3
219219
The use of magic ``__call()`` method was introduced in Symfony 2.3.
220220

221221
.. caution::
222222

223223
The ``__call`` feature is disabled by default, you can enable it by calling
224-
:method:`PropertyAccessorBuilder::enableMagicCallEnabled<Symfony\\Component\\PropertyAccess\\PropertyAccessorBuilder::enableMagicCallEnabled>`
224+
:method:`PropertyAccessorBuilder::enableMagicCall<Symfony\\Component\\PropertyAccess\\PropertyAccessorBuilder::enableMagicCall>`
225225
see `Enable other Features`_.
226226

227227
Writing to Arrays
@@ -237,9 +237,9 @@ method::
237237

238238
$accessor->setValue($person, '[first_name]', 'Wouter');
239239

240-
echo $accessor->getValue($person, '[first_name]'); // 'Wouter'
240+
var_dump($accessor->getValue($person, '[first_name]')); // 'Wouter'
241241
// or
242-
// echo $person['first_name']; // 'Wouter'
242+
// var_dump($person['first_name']); // 'Wouter'
243243

244244
Writing to Objects
245245
------------------
@@ -273,9 +273,9 @@ can use setters, the magic ``__set`` method or properties to set values::
273273
$accessor->setValue($person, 'lastName', 'de Jong');
274274
$accessor->setValue($person, 'children', array(new Person()));
275275

276-
echo $person->firstName; // 'Wouter'
277-
echo $person->getLastName(); // 'de Jong'
278-
echo $person->children; // array(Person());
276+
var_dump($person->firstName); // 'Wouter'
277+
var_dump($person->getLastName()); // 'de Jong'
278+
var_dump($person->children); // array(Person());
279279

280280
You can also use ``__call`` to set values but you need to enable the feature,
281281
10000 see `Enable other Features`_.
@@ -311,7 +311,7 @@ see `Enable other Features`_.
311311
312312
$accessor->setValue($person, 'wouter', array(...));
313313
314-
echo $person->getWouter(); // array(...)
314+
var_dump($person->getWouter()); // array(...)
315315
316316
Checking Property Paths
317317
-----------------------
@@ -376,7 +376,7 @@ You can also mix objects and arrays::
376376
$accessor->setValue($person, 'children[0].firstName', 'Wouter');
377377
// equal to $person->getChildren()[0]->firstName = 'Wouter'
378378

379-
echo 'Hello '.$accessor->getValue($person, 'children[0].firstName'); // 'Wouter'
379+
var_dump('Hello '.$accessor->getValue($person, 'children[0].firstName')); // 'Wouter'
380380
// equal to $person->getChildren()[0]->firstName
381381

382382
Enable other Features

components/security/authorization.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,8 +191,8 @@ first constructor argument::
191191

192192
$role = new Role('ROLE_ADMIN');
193193

194-
// will echo 'ROLE_ADMIN'
195-
echo $role->getRole();
194+
// will show 'ROLE_ADMIN'
195+
var_dump($role->getRole());
196196

197197
.. note::
198198

@@ -253,3 +253,4 @@ decision manager::
253253
if (!$authorizationChecker->isGranted('ROLE_ADMIN')) {
254254
throw new AccessDeniedException();
255255
}
256+

0 commit comments

Comments
 (0)
0