vendor/pimcore/pimcore/lib/Routing/DocumentRoute.php line 25

Open in your IDE?
  1. <?php
  2. /**
  3. * Pimcore
  4. *
  5. * This source file is available under two different licenses:
  6. * - GNU General Public License version 3 (GPLv3)
  7. * - Pimcore Commercial License (PCL)
  8. * Full copyright and license information is available in
  9. * LICENSE.md which is distributed with this source code.
  10. *
  11. * @copyright Copyright (c) Pimcore GmbH (http://www.pimcore.org)
  12. * @license http://www.pimcore.org/license GPLv3 and PCL
  13. */
  14. namespace Pimcore\Routing;
  15. use Pimcore\Model\Document;
  16. use Symfony\Cmf\Component\Routing\RouteObjectInterface;
  17. use Symfony\Component\Routing\Route;
  18. /**
  19. * @internal
  20. */
  21. final class DocumentRoute extends Route implements RouteObjectInterface
  22. {
  23. /**
  24. * @var Document|null
  25. */
  26. protected $document;
  27. /**
  28. * @return Document|null
  29. */
  30. public function getDocument(): ?Document
  31. {
  32. return $this->document;
  33. }
  34. /**
  35. * @param Document $document
  36. *
  37. * @return $this
  38. */
  39. public function setDocument($document)
  40. {
  41. $this->document = $document;
  42. return $this;
  43. }
  44. /**
  45. * {@inheritdoc}
  46. */
  47. public function getContent(): ?object
  48. {
  49. return $this->getDocument();
  50. }
  51. /**
  52. * {@inheritdoc}
  53. */
  54. public function getRouteKey(): ?string
  55. {
  56. if ($this->document) {
  57. return sprintf('document_%d', $this->document->getId());
  58. }
  59. return null;
  60. }
  61. }