Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite76f69f

Browse files
committed
Merge branch '2.2'
Conflicts:components/filesystem.rst
2 parentsc9b65d0 +28b0904 commite76f69f

File tree

9 files changed

+96
-41
lines changed

9 files changed

+96
-41
lines changed

‎book/controller.rst‎

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,7 @@ value to each variable.
476476

477477
Like other base ``Controller`` methods, the ``forward`` method is just
478478
a shortcut for core Symfony2 functionality. A forward can be accomplished
479-
directly via the ``http_kernel`` service. A forward returns a ``Response``
479+
directly via the ``http_kernel`` service and returns a ``Response``
480480
object::
481481

482482
$httpKernel = $this->container->get('http_kernel');
@@ -687,19 +687,23 @@ the ``notice`` message:
687687

688688
..code-block::html+jinja
689689

690-
{% for flashMessage in app.session.flashbag.get('notice') %}
691-
<div class="flash-notice">
692-
{{ flashMessage }}
693-
</div>
694-
{% endfor %}
690+
{% if app.session.started %}
691+
{% for flashMessage in app.session.flashbag.get('notice') %}
692+
<div class="flash-notice">
693+
{{ flashMessage }}
694+
</div>
695+
{% endfor %}
696+
{% endif %}
695697

696698
..code-block::html+php
697699

698-
<?php foreach ($view['session']->getFlashBag()->get('notice') as $message): ?>
699-
<div class="flash-notice">
700-
<?php echo "<div class='flash-error'>$message</div>" ?>
701-
</div>
702-
<?php endforeach; ?>
700+
<?php if ($view['session']->isStarted()): ?>
701+
<?php foreach ($view['session']->getFlashBag()->get('notice') as $message): ?>
702+
<div class="flash-notice">
703+
<?php echo "<div class='flash-error'>$message</div>" ?>
704+
</div>
705+
<?php endforeach; ?>
706+
<?php endif; ?>
703707

704708
By design, flash messages are meant to live for exactly one request (they're
705709
"gone in a flash"). They're designed to be used across redirects exactly as

‎book/stable_api.rst‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ As of Symfony 2.0, the following components have a public tagged API:
3131
* DependencyInjection
3232
* DomCrawler
3333
* EventDispatcher
34+
* Filesystem (as of Symfony 2.1)
3435
* Finder
3536
* HttpFoundation
3637
* HttpKernel

‎components/filesystem.rst‎

Lines changed: 38 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,9 @@ endpoint for filesystem operations::
4747
Mkdir
4848
~~~~~
4949

50-
Mkdir creates directory. On posix filesystems, directories are created with a
51-
default mode value `0777`. You can use the second argument to set your own mode::
50+
:method:`Symfony\\Component\\Filesystem\\Filesystem::mkdir` creates directory.
51+
On posix filesystems, directories are created with a default mode value
52+
`0777`. You can use the second argument to set your own mode::
5253

5354
$fs->mkdir('/tmp/photos', 0700);
5455

@@ -60,8 +61,8 @@ default mode value `0777`. You can use the second argument to set your own mode:
6061
Exists
6162
~~~~~~
6263

63-
Exists checks for the presence of all files or directories and returns false if a
64-
file is missing::
64+
:method:`Symfony\\Component\\Filesystem\\Filesystem::exists` checks for the
65+
presence of all files or directories and returns false if afile is missing::
6566

6667
// this directory exists, return true
6768
$fs->exists('/tmp/photos');
@@ -77,9 +78,10 @@ file is missing::
7778
Copy
7879
~~~~
7980

80-
This method is used to copy files. If the target already exists, the file is
81-
copied only if the source modification date is later than the target. This
82-
behavior can be overridden by the third boolean argument::
81+
:method:`Symfony\\Component\\Filesystem\\Filesystem::copy` is used to copy
82+
files. If the target already exists, the file is copied only if the source
83+
modification date is later than the target. This behavior can be overridden by
84+
the third boolean argument::
8385

8486
// works only if image-ICC has been modified after image.jpg
8587
$fs->copy('image-ICC.jpg', 'image.jpg');
@@ -90,9 +92,9 @@ behavior can be overridden by the third boolean argument::
9092
Touch
9193
~~~~~
9294

93-
Touch sets access and modification time for a file. The current time is used by
94-
default. You can set your own with the second argument. The third argument is
95-
the access time::
95+
:method:`Symfony\\Component\\Filesystem\\Filesystem::touch` sets access and
96+
modification time for a file. The current time is used by default. You can set
97+
your own with the second argument. The third argument isthe access time::
9698

9799
// set modification time to the current timestamp
98100
$fs->touch('file.txt');
@@ -109,8 +111,8 @@ the access time::
109111
Chown
110112
~~~~~
111113

112-
Chown is used to change the owner of a file. The third argument is a boolean
113-
recursive option::
114+
:method:`Symfony\\Component\\Filesystem\\Filesystem::chown` is used to change
115+
the owner of a file. The third argument is a booleanrecursive option::
114116

115117
// set the owner of the lolcat video to www-data
116118
$fs->chown('lolcat.mp4', 'www-data');
@@ -125,8 +127,8 @@ recursive option::
125127
Chgrp
126128
~~~~~
127129

128-
Chgrp is used to change the group of a file. The third argument is a boolean
129-
recursive option::
130+
:method:`Symfony\\Component\\Filesystem\\Filesystem::chgrp` is used to change
131+
the group of a file. The third argument is a booleanrecursive option::
130132

131133
// set the group of the lolcat video to nginx
132134
$fs->chgrp('lolcat.mp4', 'nginx');
@@ -142,8 +144,8 @@ recursive option::
142144
Chmod
143145
~~~~~
144146

145-
Chmod is used to change the mode of a file. The fourth argument is a boolean
146-
recursive option::
147+
:method:`Symfony\\Component\\Filesystem\\Filesystem::chmod` is used to change
148+
the mode of a file. The fourth argument is a booleanrecursive option::
147149

148150
// set the mode of the video to 0600
149151
$fs->chmod('video.ogg', 0600);
@@ -158,7 +160,8 @@ recursive option::
158160
Remove
159161
~~~~~~
160162

161-
Remove let's you remove files, symlink, directories easily::
163+
:method:`Symfony\\Component\\Filesystem\\Filesystem::remove` let's you remove
164+
files, symlink, directories easily::
162165

163166
$fs->remove(array('symlink', '/path/to/directory', 'activity.log'));
164167

@@ -170,7 +173,8 @@ Remove let's you remove files, symlink, directories easily::
170173
Rename
171174
~~~~~~
172175

173-
Rename is used to rename files and directories::
176+
:method:`Symfony\\Component\\Filesystem\\Filesystem::rename` is used to rename
177+
files and directories::
174178

175179
//rename a file
176180
$fs->rename('/tmp/processed_video.ogg', '/path/to/store/video_647.ogg');
@@ -180,8 +184,9 @@ Rename is used to rename files and directories::
180184
symlink
181185
~~~~~~~
182186

183-
Creates a symbolic link from the target to the destination. If the filesystem
184-
does not support symbolic links, a third boolean argument is available::
187+
:method:`Symfony\\Component\\Filesystem\\Filesystem::symlink` creates a
188+
symbolic link from the target to the destination. If the filesystem does not
189+
support symbolic links, a third boolean argument is available::
185190

186191
// create a symbolic link
187192
$fs->symlink('/path/to/source', '/path/to/destination');
@@ -192,7 +197,8 @@ does not support symbolic links, a third boolean argument is available::
192197
makePathRelative
193198
~~~~~~~~~~~~~~~~
194199

195-
Return the relative path of a directory given another one::
200+
:method:`Symfony\\Component\\Filesystem\\Filesystem::makePathRelative` returns
201+
the relative path of a directory given another one::
196202

197203
// returns '../'
198204
$fs->makePathRelative(
@@ -205,14 +211,16 @@ Return the relative path of a directory given another one::
205211
mirror
206212
~~~~~~
207213

208-
Mirrors a directory::
214+
:method:`Symfony\\Component\\Filesystem\\Filesystem::mirror` mirrors a
215+
directory::
209216

210217
$fs->mirror('/path/to/source', '/path/to/target');
211218

212219
isAbsolutePath
213220
~~~~~~~~~~~~~~
214221

215-
isAbsolutePath returns true if the given path is absolute, false otherwise::
222+
:method:`Symfony\\Component\\Filesystem\\Filesystem::isAbsolutePath` returns
223+
``true`` if the given path is absolute, false otherwise::
216224

217225
// return true
218226
$fs->isAbsolutePath('/tmp');
@@ -248,4 +256,11 @@ Whenever something wrong happens, an exception implementing
248256
:class:`Symfony\\Component\\Filesystem\\Exception\\ExceptionInterface` is
249257
thrown.
250258

259+
..note::
260+
261+
Prior to version 2.1, ``mkdir`` returned a boolean and did not throw
262+
exceptions. As of 2.1, a
263+
:class:`Symfony\\Component\\Filesystem\\Exception\\IOException` is thrown
264+
if a directory creation fails.
265+
251266
.. _`Packagist`:https://packagist.org/packages/symfony/filesystem

‎components/http_foundation/sessions.rst‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,3 +329,16 @@ Compact method to process display all flashes at once::
329329
echo "<div class='flash-$type'>$message</div>\n";
330330
}
331331
}
332+
333+
..caution::
334+
335+
As flash messages use a session to store the messages from one request to
336+
the next one, a session will be automatically started when you read the
337+
flash messages even if none already exists. To avoid that default
338+
behavior, test if there is an existing session first::
339+
340+
if ($session->isStarted()) {
341+
foreach ($session->getFlashBag()->get('warning', array()) as $message) {
342+
echo "<div class='flash-warning'>$message</div>";
343+
}
344+
}

‎components/http_kernel/introduction.rst‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -611,7 +611,7 @@ a built-in ControllerResolver that can be used to create a working example::
611611
'_controller' => function (Request $request) {
612612
return new Response(sprintf("Hello %s", $request->get('name')));
613613
}
614-
),
614+
)
615615
));
616616

617617
$request = Request::createFromGlobals();

‎components/security/authentication.rst‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ from the user data storage, hash the password the user has just provided
119119
the given password is valid.
120120

121121
This functionality is offered by the:class:`Symfony\\Component\\Security\\Core\\Authentication\\Provider\\DaoAuthenticationProvider`.
122-
It fetches the user's data from a:class:`Symfony\\Component\\Security\\Core\\User\\UserProviderInterface``,
122+
It fetches the user's data from a:class:`Symfony\\Component\\Security\\Core\\User\\UserProviderInterface`,
123123
uses a:class:`Symfony\\Component\\Security\\Core\\Encoder\\PasswordEncoderInterface`
124124
to create a hash of the password and returns an authenticated token if the
125125
password was valid::

‎cookbook/security/target_path.rst‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ Next, create your own ``ExceptionListener``::
6262
return;
6363
}
6464

65-
$request->getSession()->set('_security.main.target_path',$request->getUri());
65+
parent::setTargetPath($request);
6666
}
6767
}
6868

69-
Add as much or few logic here as required for your scenario!
69+
Add as much or few logic here as required for your scenario!

‎quick_tour/the_controller.rst‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,11 @@ next request::
141141

142142
// display any messages back in the next request (in a template)
143143

144-
{% for flashMessage in app.session.flashbag.get('notice') %}
145-
<div>{{ flashMessage }}</div>
146-
{% endfor %}
144+
{% if app.session.started %}
145+
{% for flashMessage in app.session.flashbag.get('notice') %}
146+
<div>{{ flashMessage }}</div>
147+
{% endfor %}
148+
{% endif %}
147149

148150
This is useful when you need to set a success message before redirecting
149151
the user to another page (which will then show the message). Please note that

‎reference/dic_tags.rst‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ may also be tags in other bundles you use that aren't listed here.
3131
+-----------------------------------+---------------------------------------------------------------------------+
3232
| `data_collector`_| Create a class that collects custom data for the profiler|
3333
+-----------------------------------+---------------------------------------------------------------------------+
34+
| `doctrine.event_listener`_| Add a Doctrine event listener|
35+
+-----------------------------------+---------------------------------------------------------------------------+
36+
| `doctrine.event_subscriber`_| Add a Doctrine event subscriber|
37+
+-----------------------------------+---------------------------------------------------------------------------+
3438
| `form.type`_| Create a custom form field type|
3539
+-----------------------------------+---------------------------------------------------------------------------+
3640
| `form.type_extension`_| Create a custom "form extension"|
@@ -239,6 +243,22 @@ data_collector
239243
For details on creating your own custom data collection, read the cookbook
240244
article: :doc:`/cookbook/profiler/data_collector`.
241245
246+
doctrine.event_listener
247+
--------------
248+
249+
**Purpose**: Add a Doctrine event listener
250+
251+
For details on creating Doctrine event listeners, read the cookbook article:
252+
:doc:`/cookbook/doctrine/event_listeners_subscribers`.
253+
254+
doctrine.event_subscriber
255+
--------------
256+
257+
**Purpose**: Add a Doctrine event subscriber
258+
259+
For details on creating Doctrine event subscribers, read the cookbook article:
260+
:doc:`/cookbook/doctrine/event_listeners_subscribers`.
261+
242262
.. _dic-tags-form-type:
243263
244264
form.type

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp