SlugHandlerInterface.php 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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 Doctrine\Common\Persistence\ObjectManager $om
  25. * @param Gedmo\Sluggable\SluggableListener $sluggable
  26. */
  27. function __construct(ObjectManager $om, SluggableListener $sluggable);
  28. /**
  29. * Get the options for specific object
  30. *
  31. * @param object $object
  32. * @return array
  33. */
  34. function getOptions($object);
  35. /**
  36. * Callback on slug handlers right after the slug is built
  37. *
  38. * @param Gedmo\Sluggable\Mapping\Event\SluggableAdapter $ea
  39. * @param array $config
  40. * @param object $object
  41. * @param string $slug
  42. * @return void
  43. */
  44. function postSlugBuild(SluggableAdapter $ea, array &$config, $object, &$slug);
  45. /**
  46. * Callback for slug handlers on slug completion
  47. *
  48. * @param Gedmo\Sluggable\Mapping\Event\SluggableAdapter $ea
  49. * @param array $config
  50. * @param object $object
  51. * @param string $slug
  52. * @return void
  53. */
  54. function onSlugCompletion(SluggableAdapter $ea, array &$config, $object, &$slug);
  55. /**
  56. * Validate handler options
  57. *
  58. * @param array $options
  59. */
  60. static function validate(array $options, ClassMetadata $meta);
  61. }