You are here

class WeightNodeHandler in Weight 7.2

Hierarchy

Expanded class hierarchy of WeightNodeHandler

1 string reference to 'WeightNodeHandler'
weight_migrate_api in ./weight.migrate.inc
Implements hook_migrate_api().

File

./weight.migrate.inc, line 20
Migrate support for weight.

View source
class WeightNodeHandler extends MigrateDestinationHandler {
  public function __construct() {
    $this
      ->registerTypes(array(
      'node',
    ));
  }
  public function fields($entity_type, $bundle) {
    $settings = _weight_get_settings($bundle);
    if (!empty($settings) && $settings['enabled']) {
      return array(
        'weight' => t('The node weight ranging between @min and @max.', array(
          '@max' => $settings['range'],
          '@min' => (int) $settings['range'] * -1,
        )),
      );
    }
  }
  public function prepare($entity, stdClass $row) {
    $settings = _weight_get_settings($entity->type);
    if (!empty($settings) && $settings['enabled']) {

      // Use the mapped entity value to populate the real value
      if (isset($entity->weight)) {
        $entity->weight_weight = $entity->weight;
        unset($entity->weight);
      }
      else {
        $entity->weight_weight = $settings['default'];
      }
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
MigrateHandler::$dependencies protected property List of other handler classes which should be invoked before the current one.
MigrateHandler::$typesHandled protected property List of "types" handled by this handler. Depending on the kind of handler, these may be destination types, field types, etc.
MigrateHandler::getDependencies public function
MigrateHandler::getTypesHandled public function
MigrateHandler::handlesType public function Does this handler handle the given type? 1
MigrateHandler::registerTypes protected function Register a list of types handled by this class
WeightNodeHandler::fields public function
WeightNodeHandler::prepare public function
WeightNodeHandler::__construct public function Overrides MigrateHandler::__construct