handler.inc 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?php
  2. /**
  3. * @file
  4. * Defines the base class for destination handlers.
  5. */
  6. /**
  7. * Abstract base class for destination handlers. Handler objects are expected
  8. * to implement appropriate methods (e.g., prepare, complete, or fields).
  9. */
  10. abstract class MigrateHandler {
  11. /**
  12. * List of other handler classes which should be invoked before the current one.
  13. *
  14. * @var array
  15. */
  16. protected $dependencies = array();
  17. public function getDependencies() {
  18. return $this->dependencies;
  19. }
  20. /**
  21. * List of "types" handled by this handler. Depending on the kind of handler,
  22. * these may be destination types, field types, etc.
  23. *
  24. * @var array
  25. */
  26. protected $typesHandled = array();
  27. public function getTypesHandled() {
  28. return $this->typesHandled;
  29. }
  30. /**
  31. * Register a list of types handled by this class
  32. *
  33. * @param array $types
  34. */
  35. protected function registerTypes(array $types) {
  36. // Make the type names the keys
  37. foreach ($types as $type) {
  38. $type = drupal_strtolower($type);
  39. $this->typesHandled[$type] = $type;
  40. }
  41. }
  42. /**
  43. * Does this handler handle the given type?
  44. *
  45. * @param boolean $type
  46. */
  47. public function handlesType($type) {
  48. return isset($this->typesHandled[strtolower($type)]);
  49. }
  50. abstract public function __construct();
  51. }