SlugHandlerInterface.php 2.1 KB

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