NativeLabelTranslatorStrategy.php 764 B

1234567891011121314151617181920212223242526272829
  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\AdminBundle\Translator;
  11. /**
  12. * @author Thomas Rabaix <thomas.rabaix@sonata-project.org>
  13. */
  14. class NativeLabelTranslatorStrategy implements LabelTranslatorStrategyInterface
  15. {
  16. /**
  17. * {@inheritdoc}
  18. */
  19. public function getLabel($label, $context = '', $type = '')
  20. {
  21. $label = str_replace(array('_', '.'), ' ', $label);
  22. $label = strtolower(preg_replace('~(?<=\\w)([A-Z])~', '_$1', $label));
  23. return trim(ucwords(str_replace('_', ' ', $label)));
  24. }
  25. }