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

Appearance settings

Commit e2c24fa

Browse filesBrowse files
committed
Merge branch '2.0'
Conflicts: cookbook/form/form_collections.rst
2 parents e80ac5c + 455cd00 commit e2c24fa
Copy full SHA for e2c24fa

File tree

Expand file treeCollapse file tree

10 files changed

+111
-11
lines changed
Filter options
Expand file treeCollapse file tree

10 files changed

+111
-11
lines changed

‎book/forms.rst

Copy file name to clipboardExpand all lines: book/forms.rst
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -567,7 +567,7 @@ the correct values of a number of field options.
567567
And though you'll need to manually add your server-side validation, these
568568
field type options can then be guessed from that information.
569569

570-
* ``required``: The ``required`` option can be guessed based off of the validation
570+
* ``required``: The ``required`` option can be guessed based on the validation
571571
rules (i.e. is the field ``NotBlank`` or ``NotNull``) or the Doctrine metadata
572572
(i.e. is the field ``nullable``). This is very useful, as your client-side
573573
validation will automatically match your validation rules.

‎book/page_creation.rst

Copy file name to clipboardExpand all lines: book/page_creation.rst
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ that controller.
203203

204204
The controller - ``AcmeHelloBundle:Hello:index`` is the *logical* name of
205205
the controller, and it maps to the ``indexAction`` method of a PHP class
206-
called ``Acme\HelloBundle\Controller\Hello``. Start by creating this file
206+
called ``Acme\HelloBundle\Controller\HelloController``. Start by creating this file
207207
inside your ``AcmeHelloBundle``::
208208

209209
// src/Acme/HelloBundle/Controller/HelloController.php
@@ -274,7 +274,7 @@ An optional, but common, third step in the process is to create a template.
274274
Optional Step 3: Create the Template
275275
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
276276

277-
Templates allows you to move all of the presentation (e.g. HTML code) into
277+
Templates allow you to move all of the presentation (e.g. HTML code) into
278278
a separate file and reuse different portions of the page layout. Instead
279279
of writing the HTML inside the controller, render a template instead:
280280

‎book/performance.rst

Copy file name to clipboardExpand all lines: book/performance.rst
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ application even faster.
1515
Use a Byte Code Cache (e.g. APC)
1616
--------------------------------
1717

18-
One the best (and easiest) things that you should do to improve your performance
18+
One of the best (and easiest) things that you should do to improve your performance
1919
is to use a "byte code cache". The idea of a byte code cache is to remove
2020
the need to constantly recompile the PHP source code. There are a number of
2121
`byte code caches`_ available, some of which are open source. The most widely

‎book/propel.rst

Copy file name to clipboardExpand all lines: book/propel.rst
+5-2Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,11 @@ persist it to the database and fetch it back out.
1818
.. sidebar:: Code along with the example
1919

2020
If you want to follow along with the example in this chapter, create an
21-
``AcmeStoreBundle`` via: ``php app/console generate:bundle
22-
--namespace=Acme/StoreBundle``.
21+
``AcmeStoreBundle`` via:
22+
23+
.. code-block:: bash
24+
25+
php app/console generate:bundle --namespace=Acme/StoreBundle
2326
2427
Configuring the Database
2528
~~~~~~~~~~~~~~~~~~~~~~~~

‎book/validation.rst

Copy file name to clipboardExpand all lines: book/validation.rst
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ workflow looks like the following from inside a controller::
221221

222222
public function updateAction(Request $request)
223223
{
224-
$author = new Acme\BlogBundle\Entity\Author();
224+
$author = new Author();
225225
$form = $this->createForm(new AuthorType(), $author);
226226

227227
if ($request->getMethod() == 'POST') {

‎components/dependency_injection/tags.rst

Copy file name to clipboardExpand all lines: components/dependency_injection/tags.rst
+97Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,3 +157,100 @@ run when the container is compiled::
157157

158158
$container = new ContainerBuilder();
159159
$container->addCompilerPass(new TransportCompilerPass);
160+
161+
Adding additional attributes on Tags
162+
------------------------------------
163+
164+
Sometimes you need additional information about each service that's tagged with your tag.
165+
For example, you might want to add an alias to each TransportChain.
166+
167+
To begin with, change the ``TransportChain`` class::
168+
169+
class TransportChain
170+
{
171+
private $transports;
172+
173+
public function __construct()
174+
{
175+
$this->transports = array();
176+
}
177+
178+
public function addTransport(\Swift_Transport $transport, $alias)
179+
{
180+
$this->transports[$alias] = $transport;
181+
}
182+
183+
public function getTransport($alias)
184+
{
185+
if (array_key_exists($alias, $this->transports)) {
186+
return $this->transports[$alias];
187+
}
188+
else {
189+
return null;
190+
}
191+
}
192+
}
193+
194+
As you can see, when ``addTransport`` is called, it takes not only a ``Swift_Transport``
195+
object, but also a string alias for that transport. So, how can we allow
196+
each tagged transport service to also supply an alias?
197+
198+
To answer this, change the service declaration:
199+
200+
.. configuration-block::
201+
202+
.. code-block:: yaml
203+
204+
services:
205+
acme_mailer.transport.smtp:
206+
class: \Swift_SmtpTransport
207+
arguments:
208+
- %mailer_host%
209+
tags:
210+
- { name: acme_mailer.transport, alias: foo }
211+
acme_mailer.transport.sendmail:
212+
class: \Swift_SendmailTransport
213+
tags:
214+
- { name: acme_mailer.transport, alias: bar }
215+
216+
217+
.. code-block:: xml
218+
219+
<service id="acme_mailer.transport.smtp" class="\Swift_SmtpTransport">
220+
<argument>%mailer_host%</argument>
221+
<tag name="acme_mailer.transport" alias="foo" />
222+
</service>
223+
224+
<service id="acme_mailer.transport.sendmail" class="\Swift_SendmailTransport">
225+
<tag name="acme_mailer.transport" alias="bar" />
226+
</service>
227+
228+
Notice that you've added a generic ``alias`` key to the tag. To actually
229+
use this, update the compiler::
230+
231+
use Symfony\Component\DependencyInjection\ContainerBuilder;
232+
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
233+
use Symfony\Component\DependencyInjection\Reference;
234+
235+
class TransportCompilerPass implements CompilerPassInterface
236+
{
237+
public function process(ContainerBuilder $container)
238+
{
239+
if (false === $container->hasDefinition('acme_mailer.transport_chain')) {
240+
return;
241+
}
242+
243+
$definition = $container->getDefinition('acme_mailer.transport_chain');
244+
245+
foreach ($container->findTaggedServiceIds('acme_mailer.transport') as $id => $tagAttributes) {
246+
foreach ($tagAttributes as $attributes) {
247+
$definition->addMethodCall('addTransport', array(new Reference($id), $attributes["alias"]));
248+
}
249+
}
250+
}
251+
}
252+
253+
The trickiest part is the ``$attributes`` variable. Because you can use the
254+
same tag many times on the same service (e.g. you could theoretically tag
255+
the same service 5 times with the ``acme_mailer.transport`` tag), ``$attributes``
256+
is an array of the tag information for each tag on that service.

‎components/routing.rst

Copy file name to clipboardExpand all lines: components/routing.rst
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ your autoloader to load the Routing component::
4848

4949
Be careful when using ``$_SERVER['REQUEST_URI']``, as it may include
5050
any query parameters on the URL, which will cause problems with route
51-
matching. An easy way to solve this is to use the HTTPFoundation component
51+
matching. An easy way to solve this is to use the HttpFoundation component
5252
as explained :ref:`below<components-routing-http-foundation>`.
5353

5454
You can add as many routes as you like to a

‎contributing/documentation/format.rst

Copy file name to clipboardExpand all lines: contributing/documentation/format.rst
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ markup syntax and parser system".
1313
You can learn more about its syntax by reading existing Symfony2 `documents`_
1414
or by reading the `reStructuredText Primer`_ on the Sphinx website.
1515

16-
If you are familiar with Markdown, be careful as things as sometimes very
16+
If you are familiar with Markdown, be careful as things are sometimes very
1717
similar but different:
1818

1919
* Lists starts at the beginning of a line (no indentation is allowed);

‎cookbook/form/form_collections.rst

Copy file name to clipboardExpand all lines: cookbook/form/form_collections.rst
-1Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,6 @@ new "tag" forms. To render it, make the following change to your template:
339339

340340
{{ form_widget(form.tags.vars.prototype.name) | e }}
341341

342-
343342
On the rendered page, the result will look something like this:
344343

345344
.. code-block:: html

‎cookbook/security/acl.rst

Copy file name to clipboardExpand all lines: cookbook/security/acl.rst
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,7 @@ added above:
199199

200200
.. code-block:: php
201201
202-
$acl->insertObjectAce(new UserSecurityIdentity('johannes'), $mask);
202+
$identity = new UserSecurityIdentity('johannes', 'Acme\UserBundle\Entity\User');
203+
$acl->insertObjectAce($identity, $mask);
203204
204205
The user is now allowed to view, edit, delete, and un-delete objects.

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.