Skip to content

Review components chapter #10586

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 26, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions components/asset.rst
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ corresponding output file:
"...": "..."
}

In those cases, use the
In those cases, use the
:class:`Symfony\\Component\\Asset\\VersionStrategy\\JsonManifestVersionStrategy`::

use Symfony\Component\Asset\Package;
Expand Down Expand Up @@ -282,8 +282,8 @@ You can also pass a schema-agnostic URL::
// result: //static.example.com/images/logo.png?v1

This is useful because assets will automatically be requested via HTTPS if
a visitor is viewing your site in https. Just make sure that your CDN host
supports https.
a visitor is viewing your site in https. If you want to use this, make sure
that your CDN host supports HTTPS.

In case you serve assets from more than one domain to improve application
performance, pass an array of URLs as the first argument to the ``UrlPackage``
Expand Down
2 changes: 1 addition & 1 deletion components/console/changing_default_command.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Changing the Default Command
============================

The Console component will always run the ``ListCommand`` when no command name is
passed. In order to change the default command you just need to pass the command
passed. In order to change the default command you need to pass the command
name to the ``setDefaultCommand()`` method::

namespace Acme\Console\Command;
Expand Down
4 changes: 2 additions & 2 deletions components/console/helpers/formatterhelper.rst
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,10 @@ Custom Suffix
~~~~~~~~~~~~~

By default, the ``...`` suffix is used. If you wish to use a different suffix,
simply pass it as the third argument to the method.
pass it as the third argument to the method.
The suffix is always appended, unless truncate length is longer than a message
and a suffix length.
If you don't want to use suffix at all, just pass an empty string::
If you don't want to use suffix at all, pass an empty string::

$truncatedMessage = $formatter->truncate($message, 7, '!!'); // result: This is!!
$truncatedMessage = $formatter->truncate($message, 7, ''); // result: This is
Expand Down
2 changes: 1 addition & 1 deletion components/console/helpers/progressbar.rst
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ value and then call the ``setMaxSteps()`` method to update it as needed::
.. versionadded:: 4.1
The ``setMaxSteps()`` method was introduced in Symfony 4.1.

Another solution is to just omit the steps argument when creating the
Another solution is to omit the steps argument when creating the
:class:`Symfony\\Component\\Console\\Helper\\ProgressBar` instance::

$progressBar = new ProgressBar($output);
Expand Down
2 changes: 1 addition & 1 deletion components/console/single_command_tool.rst
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ The method :method:`Symfony\\Component\\Console\\Application::setDefaultCommand`
accepts a boolean as second parameter. If true, the command ``echo`` will then
always be used, without having to pass its name.

Of course, you can still register a command as usual::
You can still register a command as usual::

#!/usr/bin/env php
<?php
Expand Down
2 changes: 1 addition & 1 deletion components/console/usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ commands, then you can run ``help`` like this:

$ php application.php h

If you have commands using ``:`` to namespace commands then you just have
If you have commands using ``:`` to namespace commands then you only need
to type the shortest unambiguous text for each part. If you have created the
``demo:greet`` as shown in :doc:`/components/console` then you
can run it with:
Expand Down
4 changes: 2 additions & 2 deletions components/debug.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Usage
-----

The Debug component provides several tools to help you debug PHP code.
Enabling them all is as easy as it can get::
Enabling them all can be done by calling the static method ``Debug::enable()``::

use Symfony\Component\Debug\Debug;

Expand Down Expand Up @@ -80,7 +80,7 @@ throw more helpful exceptions when a class isn't found by the registered
autoloaders. All autoloaders that implement a ``findFile()`` method are replaced
with a ``DebugClassLoader`` wrapper.

Using the ``DebugClassLoader`` is as easy as calling its static
To activate the ``DebugClassLoader``, call its static
:method:`Symfony\\Component\\Debug\\DebugClassLoader::enable` method::

use Symfony\Component\Debug\DebugClassLoader;
Expand Down
2 changes: 1 addition & 1 deletion components/dependency_injection.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Basic Usage
independent component in any PHP application. Read the :doc:`/service_container`
article to learn about how to use it in Symfony applications.

You might have a simple class like the following ``Mailer`` that
You might have a class like the following ``Mailer`` that
you want to make available as a service::

class Mailer
Expand Down
4 changes: 2 additions & 2 deletions components/dependency_injection/compilation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ need to be parsed and the PHP configuration built from them. The compilation
process makes the container more efficient but it takes time to run. You
can have the best of both worlds though by using configuration files and
then dumping and caching the resulting configuration. The ``PhpDumper``
makes dumping the compiled container easy::
serves at dumping the compiled container::

use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Dumper\PhpDumper;
Expand Down Expand Up @@ -534,7 +534,7 @@ You do not need to work out which files to cache as the container builder
keeps track of all the resources used to configure it, not just the
configuration files but the extension classes and compiler passes as well.
This means that any changes to any of these files will invalidate the cache
and trigger the container being rebuilt. You just need to ask the container
and trigger the container being rebuilt. You need to ask the container
for these resources and use them as metadata for the cache::

// ...
Expand Down
6 changes: 3 additions & 3 deletions components/dom_crawler.rst
Original file line number Diff line number Diff line change
Expand Up @@ -75,16 +75,16 @@ tree.
Node Filtering
~~~~~~~~~~~~~~

Using XPath expressions is really easy::
Using XPath expressions, you can select specific nodes within the document::

$crawler = $crawler->filterXPath('descendant-or-self::body/p');

.. tip::

``DOMXPath::query`` is used internally to actually perform an XPath query.

Filtering is even easier if you have the CssSelector component installed.
This allows you to use jQuery-like selectors to traverse::
If you prefer CSS selectors over XPath, install the CssSelector component.
It allows you to use jQuery-like selectors to traverse::

$crawler = $crawler->filter('body > p');

Expand Down
9 changes: 4 additions & 5 deletions components/event_dispatcher.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ The Symfony EventDispatcher component implements the `Mediator`_ and `Observer`_
design patterns to make all these things possible and to make your projects
truly extensible.

Take a simple example from :doc:`the HttpKernel component </components/http_kernel>`.
Take an example from :doc:`the HttpKernel component </components/http_kernel>`.
Once a ``Response`` object has been created, it may be useful to allow other
elements in the system to modify it (e.g. add some cache headers) before
it's actually used. To make this possible, the Symfony kernel throws an
Expand Down Expand Up @@ -84,7 +84,7 @@ object itself often contains data about the event being dispatched.
Naming Conventions
..................

The unique event name can be any string, but optionally follows a few simple
The unique event name can be any string, but optionally follows a few
naming conventions:

* Use only lowercase letters, numbers, dots (``.``) and underscores (``_``);
Expand All @@ -99,8 +99,7 @@ Event Names and Event Objects
.............................

When the dispatcher notifies listeners, it passes an actual ``Event`` object
to those listeners. The base ``Event`` class is very simple: it
contains a method for stopping
to those listeners. The base ``Event`` class contains a method for stopping
:ref:`event propagation <event_dispatcher-event-propagation>`, but not much
else.

Expand Down Expand Up @@ -451,7 +450,7 @@ listeners, chaining events or even lazy loading listeners into the dispatcher ob
Dispatcher Shortcuts
~~~~~~~~~~~~~~~~~~~~

If you do not need a custom event object, you can simply rely on a plain
If you do not need a custom event object, you can rely on a plain
:class:`Symfony\\Component\\EventDispatcher\\Event` object. You do not even
need to pass this to the dispatcher as it will create one by default unless you
specifically pass one::
Expand Down
6 changes: 3 additions & 3 deletions components/event_dispatcher/generic_event.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ box, because it follows the standard observer pattern where the event object
encapsulates an event 'subject', but has the addition of optional extra
arguments.

:class:`Symfony\\Component\\EventDispatcher\\GenericEvent` has a simple
API in addition to the base class
:class:`Symfony\\Component\\EventDispatcher\\GenericEvent` adds some more
methods in addition to the base class
:class:`Symfony\\Component\\EventDispatcher\\Event`

* :method:`Symfony\\Component\\EventDispatcher\\GenericEvent::__construct`:
Expand Down Expand Up @@ -48,7 +48,7 @@ the event subject.
The following examples show use-cases to give a general idea of the flexibility.
The examples assume event listeners have been added to the dispatcher.

Simply passing a subject::
Passing a subject::

use Symfony\Component\EventDispatcher\GenericEvent;

Expand Down
20 changes: 10 additions & 10 deletions components/form.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
The Form Component
==================

The Form component allows you to easily create, process and reuse forms.
The Form component allows you to create, process and reuse forms.

The Form component is a tool to help you solve the problem of allowing end-users
to interact with the data and modify the data in your application. And though
Expand Down Expand Up @@ -34,7 +34,8 @@ Configuration
about how to use it in Symfony applications.

In Symfony, forms are represented by objects and these objects are built
by using a *form factory*. Building a form factory is simple::
by using a *form factory*. Building a form factory is done with the factory
method ``Forms::createFormFactory``::

use Symfony\Component\Form\Forms;

Expand Down Expand Up @@ -158,7 +159,7 @@ Twig Templating
~~~~~~~~~~~~~~~

If you're using the Form component to process HTML forms, you'll need a way
to easily render your form as HTML form fields (complete with field values,
to render your form as HTML form fields (complete with field values,
errors, and labels). If you use `Twig`_ as your template engine, the Form
component offers a rich integration.

Expand Down Expand Up @@ -290,7 +291,7 @@ Validation

The Form component comes with tight (but optional) integration with Symfony's
Validator component. If you're using a different solution for validation,
no problem! Simply take the submitted/bound data of your form (which is an
no problem! Take the submitted/bound data of your form (which is an
array or object) and pass it through your own validation system.

To use the integration with Symfony's Validator component, first make sure
Expand Down Expand Up @@ -362,7 +363,7 @@ you need to. If your application uses global or static variables (not usually a
good idea), then you can store the object on some static class or do something
similar.

Regardless of how you architect your application, just remember that you
Regardless of how you architect your application, remember that you
should only have one form factory and that you'll need to be able to access
it throughout your application.

Expand Down Expand Up @@ -441,8 +442,7 @@ Setting default Values
~~~~~~~~~~~~~~~~~~~~~~

If you need your form to load with some default values (or you're building
an "edit" form), simply pass in the default data when creating your form
builder:
an "edit" form), pass in the default data when creating your form builder:

.. configuration-block::

Expand Down Expand Up @@ -517,8 +517,8 @@ helper functions:
:align: center

That's it! By printing ``form_widget(form)``, each field in the form is
rendered, along with a label and error message (if there is one). As easy
as this is, it's not very flexible (yet). Usually, you'll want to render each
rendered, along with a label and error message (if there is one). While this is
convenient, it's not very flexible (yet). Usually, you'll want to render each
form field individually so you can control how the form looks. You'll learn how
to do that in the ":doc:`/form/rendering`" section.

Expand Down Expand Up @@ -651,7 +651,7 @@ Then:
3) if the form is valid, perform some action and redirect.

Luckily, you don't need to decide whether or not a form has been submitted.
Just pass the current request to the ``handleRequest()`` method. Then, the Form
Pass the current request to the ``handleRequest()`` method. Then, the Form
component will do all the necessary work for you.

.. _component-form-intro-validation:
Expand Down
8 changes: 4 additions & 4 deletions components/http_foundation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ this complexity and defines some methods for the most common tasks::
Accessing ``Accept-*`` Headers Data
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

You can easily access basic data extracted from ``Accept-*`` headers
You can access basic data extracted from ``Accept-*`` headers
by using the following methods:

:method:`Symfony\\Component\\HttpFoundation\\Request::getAcceptableContentTypes`
Expand Down Expand Up @@ -415,7 +415,7 @@ incompatibility with the HTTP specification (e.g. a wrong ``Content-Type`` heade

$response->prepare($request);

Sending the response to the client is then as simple as calling
Sending the response to the client is done by calling the method
:method:`Symfony\\Component\\HttpFoundation\\Response::send`::

$response->send();
Expand Down Expand Up @@ -545,8 +545,8 @@ Serving Files
~~~~~~~~~~~~~

When sending a file, you must add a ``Content-Disposition`` header to your
response. While creating this header for basic file downloads is easy, using
non-ASCII filenames is more involving. The
response. While creating this header for basic file downloads is straightforward,
using non-ASCII filenames is more involving. The
:method:`Symfony\\Component\\HttpFoundation\\ResponseHeaderBag::makeDisposition`
abstracts the hard work behind a simple API::

Expand Down
2 changes: 1 addition & 1 deletion components/http_foundation/session_configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ handlers by providing six callback functions which PHP calls internally at
various points in the session workflow.

The Symfony HttpFoundation component provides some by default and these can
easily serve as examples if you wish to write your own.
serve as examples if you wish to write your own.

* :class:`Symfony\\Component\\HttpFoundation\\Session\\Storage\\Handler\\PdoSessionHandler`
* :class:`Symfony\\Component\\HttpFoundation\\Session\\Storage\\Handler\\MemcachedSessionHandler`
Expand Down
6 changes: 3 additions & 3 deletions components/http_foundation/session_testing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Testing with Sessions
=====================

Symfony is designed from the ground up with code-testability in mind. In order
to make your code which utilizes session easily testable we provide two separate
to make your code which utilizes session easily testable, we provide two separate
mock storage mechanisms for both unit testing and functional testing.

Testing code using real sessions is tricky because PHP's workflow state is global
Expand Down Expand Up @@ -37,7 +37,7 @@ Unit Testing
------------

For unit testing where it is not necessary to persist the session, you should
simply swap out the default storage engine with
swap out the default storage engine with
:class:`Symfony\\Component\\HttpFoundation\\Session\\Storage\\MockArraySessionStorage`::

use Symfony\Component\HttpFoundation\Session\Storage\MockArraySessionStorage;
Expand All @@ -49,7 +49,7 @@ Functional Testing
------------------

For functional testing where you may need to persist session data across
separate PHP processes, simply change the storage engine to
separate PHP processes, change the storage engine to
:class:`Symfony\\Component\\HttpFoundation\\Session\\Storage\\MockFileSessionStorage`::

use Symfony\Component\HttpFoundation\Session\Session;
Expand Down
14 changes: 7 additions & 7 deletions components/http_foundation/sessions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ Session Management
==================

The Symfony HttpFoundation component has a very powerful and flexible session
subsystem which is designed to provide session management through a simple
subsystem which is designed to provide session management through a clear
object-oriented interface using a variety of session storage drivers.

Sessions are used via the simple :class:`Symfony\\Component\\HttpFoundation\\Session\\Session`
Sessions are used via the :class:`Symfony\\Component\\HttpFoundation\\Session\\Session`
implementation of :class:`Symfony\\Component\\HttpFoundation\\Session\\SessionInterface` interface.

.. caution::
Expand Down Expand Up @@ -62,8 +62,8 @@ Session API
The :class:`Symfony\\Component\\HttpFoundation\\Session\\Session` class implements
:class:`Symfony\\Component\\HttpFoundation\\Session\\SessionInterface`.

The :class:`Symfony\\Component\\HttpFoundation\\Session\\Session` has a simple API
as follows divided into a couple of groups.
The :class:`Symfony\\Component\\HttpFoundation\\Session\\Session` has the
following API, divided into a couple of groups.

Session Workflow
................
Expand Down Expand Up @@ -167,7 +167,7 @@ and "Remember Me" login settings or other user based state information.
This implementation allows for attributes to be stored in a structured namespace.

:class:`Symfony\\Component\\HttpFoundation\\Session\\Attribute\\AttributeBagInterface`
has a simple API
has the API

:method:`Symfony\\Component\\HttpFoundation\\Session\\Attribute\\AttributeBagInterface::set`
Sets an attribute by name (``set('name', 'value')``).
Expand Down Expand Up @@ -265,7 +265,7 @@ This is however just one application for flash messages.
caching.

:class:`Symfony\\Component\\HttpFoundation\\Session\\Flash\\FlashBagInterface`
has a simple API
has the API

:method:`Symfony\\Component\\HttpFoundation\\Session\\Flash\\FlashBagInterface::add`
Adds a flash message to the stack of specified type.
Expand Down Expand Up @@ -321,7 +321,7 @@ Examples of setting multiple flashes::

Displaying the flash messages might look as follows.

Simple, display one type of message::
Display one type of message::

// display warnings
foreach ($session->getFlashBag()->get('warning', array()) as $message) {
Expand Down
Loading