NativeLabelTranslatorStrategy.php 637 B

123456789101112131415161718192021222324252627
  1. <?php
  2. /*
  3. * This file is part of sonata-project.
  4. *
  5. * (c) 2010 Thomas Rabaix
  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. class NativeLabelTranslatorStrategy implements LabelTranslatorStrategyInterface
  12. {
  13. /**
  14. * @param string $label
  15. * @return string
  16. */
  17. public function getLabel($label)
  18. {
  19. $label = str_replace('_', ' ', $label);
  20. $label = strtolower(preg_replace('~(?<=\\w)([A-Z])~', '_$1', $label));
  21. return ucwords(str_replace('_', ' ', $label));
  22. }
  23. }