ContentRepositoryInterface.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. /*
  3. * This file is part of the Symfony CMF package.
  4. *
  5. * (c) 2011-2015 Symfony CMF
  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 Symfony\Cmf\Component\Routing;
  11. /**
  12. * Interface used by the DynamicRouter to retrieve content by it's id when
  13. * generating routes from content-id.
  14. *
  15. * This can be easily implemented using i.e. the Doctrine PHPCR-ODM
  16. * DocumentManager.
  17. *
  18. * @author Uwe Jäger
  19. */
  20. interface ContentRepositoryInterface
  21. {
  22. /**
  23. * Return a content object by it's id or null if there is none.
  24. *
  25. * If the returned content implements RouteReferrersReadInterface, it will
  26. * be used to get the route from it to generate an URL.
  27. *
  28. * @param string $id id of the content object
  29. *
  30. * @return object A content that matches this id.
  31. */
  32. public function findById($id);
  33. /**
  34. * Return the content identifier for the provided content object for
  35. * debugging purposes.
  36. *
  37. * @param object $content A content instance
  38. *
  39. * @return string|null $id id of the content object or null if unable to determine an id
  40. */
  41. public function getContentId($content);
  42. }