Permalink
Browse files

Fixes #32 - Better practice in twig extend example

  • Loading branch information...
1 parent 4e5fc6a commit 1cecce2e3c542a32e1b2804df7c96a4bc719a71c @davedevelopment davedevelopment committed Apr 16, 2012
Showing with 4 additions and 3 deletions.
  1. +4 −3 README.rst
View
@@ -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
--------------------------------------

0 comments on commit 1cecce2

Please sign in to comment.