SlugHandlerInterface.php 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <?php
  2. namespace Gedmo\Sluggable\Handler;
  3. use Doctrine\Common\Persistence\ObjectManager;
  4. use Doctrine\Common\Persistence\Mapping\ClassMetadata;
  5. use Gedmo\Sluggable\SluggableListener;
  6. use Gedmo\Sluggable\Mapping\Event\SluggableAdapter;
  7. /**
  8. * Sluggable handler interface is a common pattern for all
  9. * slug handlers which can be attached to the sluggable listener.
  10. * Usage is intented only for internal access of sluggable.
  11. * Should not be used outside of sluggable extension
  12. *
  13. * @author Gediminas Morkevicius <gediminas.morkevicius@gmail.com>
  14. * @package Gedmo.Sluggable.Handler
  15. * @subpackage SlugHandlerInterface
  16. * @link http://www.gediminasm.org
  17. * @license MIT License (http://www.opensource.org/licenses/mit-license.php)
  18. */
  19. interface SlugHandlerInterface
  20. {
  21. /**
  22. * Construct the slug handler
  23. *
  24. * @param Gedmo\Sluggable\SluggableListener $sluggable
  25. */
  26. function __construct(SluggableListener $sluggable);
  27. /**
  28. * Get the options for specific object
  29. *
  30. * @param object $object
  31. * @return array
  32. */
  33. function getOptions($object);
  34. /**
  35. * Callback on slug handlers right after the slug is built
  36. *
  37. * @param Gedmo\Sluggable\Mapping\Event\SluggableAdapter $ea
  38. * @param array $config
  39. * @param object $object
  40. * @param string $slug
  41. * @return void
  42. */
  43. function postSlugBuild(SluggableAdapter $ea, array &$config, $object, &$slug);
  44. /**
  45. * Callback for slug handlers on slug completion
  46. *
  47. * @param Gedmo\Sluggable\Mapping\Event\SluggableAdapter $ea
  48. * @param array $config
  49. * @param object $object
  50. * @param string $slug
  51. * @return void
  52. */
  53. function onSlugCompletion(SluggableAdapter $ea, array &$config, $object, &$slug);
  54. /**
  55. * Validate handler options
  56. *
  57. * @param array $options
  58. */
  59. static function validate(array $options, ClassMetadata $meta);
  60. }