Exception.php 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <?php
  2. namespace Gedmo\Translatable;
  3. /**
  4. * The exception list for Translatable behavior
  5. *
  6. * @author Gediminas Morkevicius <gediminas.morkevicius@gmail.com>
  7. * @package Gedmo.Translatable
  8. * @subpackage Exception
  9. * @link http://www.gediminasm.org
  10. * @version 2.0.0
  11. * @license MIT License (http://www.opensource.org/licenses/mit-license.php)
  12. */
  13. class Exception extends \Exception
  14. {
  15. static public function undefinedLocale()
  16. {
  17. return new self("Translatable: locale or language cannot be empty and must be set in Translatable\Listener or in the entity");
  18. }
  19. static public function singleIdentifierRequired($entityClass)
  20. {
  21. return new self("Translatable: only a single identifier column is required for the Translatable extension, entity: {$entityClass}.");
  22. }
  23. static public function pendingInserts()
  24. {
  25. return new self("Translatable: UnitOfWork has pending inserts, cannot request query execution. TranslationListener does not support Concurrent inserts and updates together, on Doctrine 2 Beta4 yet. Try flushing only inserts or updates");
  26. }
  27. static public function failedToInsert()
  28. {
  29. return new self("Translatable: failed to insert new Translation record");
  30. }
  31. static public function translationClassLoaderArgumentInvalid($type)
  32. {
  33. return new self("Translatable: invalid argument [{$type}] given for translation class retrieval.");
  34. }
  35. static public function translationClassNotFound($class)
  36. {
  37. return new self("Translatable: the translation entity class: {$class} was not found.");
  38. }
  39. static public function notValidFieldType($field, $class)
  40. {
  41. return new self("Translatable: cannot translate field - [{$field}] type is not valid and must be 'string' or 'text' in class - {$class}");
  42. }
  43. static public function fieldMustBeMapped($field, $class)
  44. {
  45. return new self("Translatable: was unable to find [{$field}] as mapped property in entity - {$class}");
  46. }
  47. static public function fieldMustNotBeMapped($field, $class)
  48. {
  49. return new self("Translatable: field [{$field}] should not be mapped as column property in entity - {$class}, since it makes no sence");
  50. }
  51. }