@@ -133,7 +133,7 @@ be significant.
133133
134134That's why Twig allows to decouple the extension definition from its
135135implementation. Following the same example as before, the first change would be
136- to remove the ``priceFilter () `` method from the extension and update the PHP
136+ to remove the ``formatPrice () `` method from the extension and update the PHP
137137callable defined in ``getFilters() ``::
138138
139139 // src/Twig/AppExtension.php
@@ -149,14 +149,14 @@ callable defined in ``getFilters()``::
149149 {
150150 return [
151151 // the logic of this filter is now implemented in a different class
152- new TwigFilter('price', [AppRuntime::class, 'priceFilter ']),
152+ new TwigFilter('price', [AppRuntime::class, 'formatPrice ']),
153153 ];
154154 }
155155 }
156156
157157Then, create the new ``AppRuntime `` class (it's not required but these classes
158158are suffixed with ``Runtime `` by convention) and include the logic of the
159- previous ``priceFilter () `` method::
159+ previous ``formatPrice () `` method::
160160
161161 // src/Twig/AppRuntime.php
162162 namespace App\Twig;
@@ -171,7 +171,7 @@ previous ``priceFilter()`` method::
171171 // extensions, you'll need to inject services using this constructor
172172 }
173173
174- public function priceFilter ($number, $decimals = 0, $decPoint = '.', $thousandsSep = ',')
174+ public function formatPrice ($number, $decimals = 0, $decPoint = '.', $thousandsSep = ',')
175175 {
176176 $price = number_format($number, $decimals, $decPoint, $thousandsSep);
177177 $price = '$'.$price;
0 commit comments