lib/composer/PageBundle/src/VisualMedia/PageBundle/Model/BasePageContentModel.php line 29

Open in your IDE?
  1. <?php
  2. /**
  3. * Base Page Model
  4. *
  5. * @author Vincent van Waasbergen <v.vanwaasbergen@visualmedia.nl>
  6. */
  7. namespace VisualMedia\PageBundle\Model;
  8. use Doctrine\ORM\Event\LifecycleEventArgs;
  9. use VisualMedia\LisaBundle\Controller\BaseController;
  10. use VisualMedia\PageBundle\Entity\BasePage;
  11. use VisualMedia\TranslationBundle\Entity\BaseChannel;
  12. use VisualMedia\TranslationBundle\Entity\BaseLocale;
  13. use VisualMedia\TranslationBundle\Traits\ContentTrait;
  14. /**
  15. * Base Page Content Model
  16. */
  17. abstract class BasePageContentModel
  18. {
  19. use ContentTrait;
  20. /**
  21. * @param BasePage $page
  22. * @param BaseLocale $locale
  23. * @param BaseChannel|null $channel
  24. */
  25. public function __construct(BasePage $page = null, BaseLocale $locale = null, ?BaseChannel $channel = null)
  26. {
  27. $this->page = $page;
  28. $this->locale = $locale;
  29. $this->channel = $channel;
  30. }
  31. /**
  32. * Function that delegates the url to the page for url nesting.
  33. * @return string
  34. */
  35. public function getUrl(): string
  36. {
  37. // When saving a contents entity, the contents holder still has the old non-saved slug.
  38. // Call the postLoad event on the page to make sure the right slug is loaded from the contents.
  39. $manager = BaseController::getDoctrineObject()->getManager();
  40. $manager->getEventManager()->dispatchEvent('postLoad', new LifecycleEventArgs($this->page, $manager));
  41. return $this->page->getUrl();
  42. }
  43. /**
  44. * @return string|null
  45. */
  46. public function getTitle(): ?string
  47. {
  48. return $this->title;
  49. }
  50. /**
  51. * @return string|null
  52. */
  53. public function getBrowserTitle(): ?string
  54. {
  55. return $this->browserTitle;
  56. }
  57. /**
  58. * @return string|null
  59. */
  60. public function getMetaDescription(): ?string
  61. {
  62. return $this->metaDescription;
  63. }
  64. /**
  65. * @return string|null
  66. */
  67. public function getSlug(): ?string
  68. {
  69. return $this->slug;
  70. }
  71. /**
  72. * @return string|null
  73. */
  74. public function getHtmlContent(): ?string
  75. {
  76. return $this->htmlContent;
  77. }
  78. }