Exception.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. namespace Gedmo\Sluggable;
  3. /**
  4. * The exception list for Sluggable behavior
  5. *
  6. * @author Gediminas Morkevicius <gediminas.morkevicius@gmail.com>
  7. * @package Gedmo.Sluggable
  8. * @subpackage Exception
  9. * @link http://www.gediminasm.org
  10. * @license MIT License (http://www.opensource.org/licenses/mit-license.php)
  11. */
  12. class Exception extends \Exception
  13. {
  14. static public function pendingInserts()
  15. {
  16. return new self("Sluggable: Unit of work has pending inserts, cannot request query execution");
  17. }
  18. static public function fieldMustBeMapped($field, $class)
  19. {
  20. return new self("Sluggable: was unable to find [{$field}] as mapped property in entity - {$class}");
  21. }
  22. static public function noFieldsToSlug($class)
  23. {
  24. return new self("Sluggable: was unable to find sluggable fields specified for Sluggable entity - {$class}");
  25. }
  26. static public function invalidSlugType($type)
  27. {
  28. return new self("Sluggable: requires slug to be 'string' type '{$type}' is detected.");
  29. }
  30. static public function invalidSlugLength($real, $prefered)
  31. {
  32. return new self("Sluggable: cannot proceed with prefered '{$prefered}' slug length, then field allows '{$real}' length.");
  33. }
  34. static public function slugFieldIsDuplicate($slugField, $class)
  35. {
  36. return new self("Sluggable: there cannot be two slug fields '{$slugField}' in class - {$class}.");
  37. }
  38. static public function slugFieldIsUnique($slugField)
  39. {
  40. return new self("Sluggable: cannot support unique slug field '{$slugField}' during concurent updates, make an index on it.");
  41. }
  42. static public function slugIsEmpty()
  43. {
  44. return new self("Sluggable: was unable to find any non empty sluggable fields, make sure they have something at least.");
  45. }
  46. static public function notValidFieldType($field, $class)
  47. {
  48. return new self("Sluggable: cannot slug field - [{$field}] type is not valid and must be 'string' in class - {$class}");
  49. }
  50. }