DeprecatedTextExtension.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. /*
  3. * This file is part of the Sonata Project package.
  4. *
  5. * (c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Sonata\CoreBundle\Twig\Extension;
  11. /**
  12. * NEXT_MAJOR : remove this class and the twig/extensions dependency.
  13. *
  14. * @deprecated since version 3.2, to be removed in 4.0.
  15. */
  16. final class DeprecatedTextExtension extends \Twig_Extensions_Extension_Text
  17. {
  18. public function twig_truncate_filter(\Twig_Environment $env, $value, $length = 30, $preserve = false, $separator = '...')
  19. {
  20. $this->notifyDeprecation();
  21. return parent::twig_truncate_filter($env, $value, $length, $preserve, $separator);
  22. }
  23. public function twig_wordwrap_filter(\Twig_Environment $env, $value, $length = 80, $separator = "\n", $preserve = false)
  24. {
  25. $this->notifyDeprecation();
  26. return parent::twig_wordwrap_filter($env, $value, $length, $separator, $preserve);
  27. }
  28. private function notifyDeprecation()
  29. {
  30. @trigger_error(
  31. 'Using the sonata.core.twig.extension.text service is deprecated since 3.2 and will be removed in 4.0'
  32. );
  33. }
  34. }