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.

MetaComponent.php 1.8KB

3 yıl önce
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <?php
  2. namespace Lc\SovBundle\Component;
  3. class MetaComponent
  4. {
  5. public function getMetaTitle($entity)
  6. {
  7. if($entity) {
  8. if(method_exists($entity, 'getMetaTitle')) {
  9. return $entity->getMetaTitle() ;
  10. }
  11. elseif(method_exists($entity, 'getTitle')) {
  12. return $entity->getTitle() ;
  13. }
  14. }
  15. return '' ;
  16. }
  17. public function getMetaDescription($entity)
  18. {
  19. if($entity) {
  20. if(method_exists($entity, 'getMetaDescription')) {
  21. return $entity->getMetaDescription() ;
  22. }
  23. elseif(method_exists($entity, 'getDescription')) {
  24. return $entity->getDescription() ;
  25. }
  26. }
  27. return '' ;
  28. }
  29. public function getOpenGraphTitle($entity)
  30. {
  31. if($entity) {
  32. if(method_exists($entity, 'getOpenGraphTitle')) {
  33. return $entity->getOpenGraphTitle() ;
  34. }
  35. elseif(method_exists($entity, 'getTitle')) {
  36. return $entity->getTitle() ;
  37. }
  38. }
  39. return '' ;
  40. }
  41. public function getOpenGraphDescription($entity)
  42. {
  43. if($entity) {
  44. if(method_exists($entity, 'getOpenGraphDescription')) {
  45. return $entity->getOpenGraphDescription() ;
  46. }
  47. elseif(method_exists($entity, 'getDescription')) {
  48. return $entity->getDescription() ;
  49. }
  50. }
  51. return '' ;
  52. }
  53. public function getOpenGraphImage($entity)
  54. {
  55. if($entity) {
  56. if(method_exists($entity, 'getOpenGraphImage')) {
  57. return $entity->getOpenGraphImage() ;
  58. }
  59. elseif(method_exists($entity, 'getImage')) {
  60. return $entity->getImage() ;
  61. }
  62. }
  63. return '' ;
  64. }
  65. }