You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

38 lines
892B

  1. <?php
  2. namespace Lc\SovBundle\Field\Filter;
  3. /**
  4. * @author La clic ! <contact@laclic.fr>
  5. */
  6. trait FilterTrait
  7. {
  8. public function getFieldPropertySnake(string $fieldName): string
  9. {
  10. return str_replace('.', '_', $fieldName);
  11. }
  12. public function getFieldPropertyBase(string $fieldName): string
  13. {
  14. return str_replace('_', '.', $fieldName);
  15. }
  16. public function isRelationField(string $fieldName, string $needle = "."): bool
  17. {
  18. return strpos($fieldName, $needle) !== false;
  19. }
  20. public function getFieldPropertyWithoutRelation(string $fieldName, string $needle = '.'): string
  21. {
  22. return substr($fieldName, strpos($fieldName, $needle) + 1);
  23. }
  24. public function getFieldPropertyRelationAlias(string $fieldName, string $needle = '.'): string
  25. {
  26. return substr($fieldName, 0, strpos($fieldName, $needle));
  27. }
  28. }