handler.inc 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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
  13. * one.
  14. *
  15. * @var array
  16. */
  17. protected $dependencies = array();
  18. public function getDependencies() {
  19. return $this->dependencies;
  20. }
  21. /**
  22. * List of "types" handled by this handler. Depending on the kind of handler,
  23. * these may be destination types, field types, etc.
  24. *
  25. * @var array
  26. */
  27. protected $typesHandled = array();
  28. public function getTypesHandled() {
  29. return $this->typesHandled;
  30. }
  31. /**
  32. * Register a list of types handled by this class
  33. *
  34. * @param array $types
  35. */
  36. protected function registerTypes(array $types) {
  37. // Make the type names the keys
  38. foreach ($types as $type) {
  39. $type = drupal_strtolower($type);
  40. $this->typesHandled[$type] = $type;
  41. }
  42. }
  43. /**
  44. * Does this handler handle the given type?
  45. *
  46. * @param boolean $type
  47. */
  48. public function handlesType($type) {
  49. return isset($this->typesHandled[strtolower($type)]);
  50. }
  51. abstract public function __construct();
  52. }