From 1cecce2e3c542a32e1b2804df7c96a4bc719a71c Mon Sep 17 00:00:00 2001 From: Dave Marshall Date: Mon, 16 Apr 2012 12:10:30 +0100 Subject: [PATCH] Fixes #32 - Better practice in twig extend example --- README.rst | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/README.rst b/README.rst index 35571ba6..28890488 100644 --- a/README.rst +++ b/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 --------------------------------------