Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixes #32 - Better practice in twig extend example

  • Loading branch information...
commit 1cecce2e3c542a32e1b2804df7c96a4bc719a71c 1 parent 4e5fc6a
@davedevelopment davedevelopment authored
Showing with 4 additions and 3 deletions.
  1. +4 −3 README.rst
View
7 README.rst
@@ -89,14 +89,15 @@ be run on your service just after it is created::
return new Twig_Environment($c['twig.loader'], $c['twig.options']);
});
- $c['twig'] = $c->extend('twig', function ($twig, $c) {
+ $c['twig'] = $c->share($c->extend('twig', function ($twig, $c) {
$twig->addExtension(new MyTwigExtension());
return $twig;
- });
+ }));
The first argument is the name of the object, the second is a function that
gets access to the object instance and the container. The return value is
-a service definition, so you need to re-assign it on the container.
+a service definition, so you need to re-assign it on the container, in this
+example re-wrapped with the ``share`` method.
Fetching the service creation function
--------------------------------------
Please sign in to comment.
Something went wrong with that request. Please try again.