0

Im extending twig with a very simple filter. Locally work perfect, no problem, but in the server(a shared hosting) im giving this error:

FatalErrorException: Error: Class 'besmart\CoreBundle\Extension\BesmartTwigExtension' not found in /home/username/public_html/mysite.com/app/cache/dev/appDevDebugProjectContainer.php line 283

this is my class:

namespace besmart\CoreBundle\Extension;
class BesmartTwigExtension extends \Twig_Extension {

    public function __construct() {

    }    
    public function getFilters()
    {
        return array(
            new \Twig_SimpleFilter('price', array($this, 'priceFilter')),
        );
    }    
    public function priceFilter($number, $decimals = 0, $decPoint = '.', $thousandsSep = ',')
    {
        $price = \number_format($number, $decimals, $decPoint, $thousandsSep);
        $price = '$'.$price;

        return $price;
    }
    public function getName() {
        return 'besmartTwigExtension';
    }

}

this is for service:

besmart.extension.besmart_twig_extension:
    class: besmart\CoreBundle\Extension\BesmartTwigExtension
    arguments: []
    tags:
        - { name: twig.extension }

and in twig(to use the filter)

    <p>
        {{ '500'|price }}Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent consectetur nisl quis tempor cursus. Donec imperdiet felis ut turpis congue tincidunt. Cras aliquam, elit et facilisis pretium,
    </p>

im recreating exactly the example of "How to write a custom Twig Extension" for symfony 2.2

Thanks in advance.

4

0 に答える 0