You are here

class MigrateDestinationBiblioType in Bibliography Module 7.3

@file

Hierarchy

Expanded class hierarchy of MigrateDestinationBiblioType

File

includes/migrate/plugins/destinations/biblio_type.inc, line 8

View source
class MigrateDestinationBiblioType extends MigrateDestination {
  public function __toString() {
    return 'biblio-type';
  }
  public static function getKeySchema() {
    return array(
      'id' => array(
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
      ),
    );
  }

  /**
   * Delete a biblio type.
   *
   * @param $type
   *  The type to be deleted.
   */
  public function rollback($type) {
    biblio_type_delete($type);
  }

  /**
   * Import a biblio type.
   *
   * @param $entity
   *  Object object to build. Filled with any fields mapped in the Migration.
   * @param $row
   *  Raw source data object - passed through to prepare/complete handlers.
   *
   * @return
   */
  public function import(stdClass $entity, stdClass $row) {
    $this
      ->prepare($entity, $row);
    if (empty($entity->type)) {
      throw new MigrateException(t('Missing biblio type.'));
    }
    if (empty($entity->description)) {
      throw new MigrateException(t('Missing description.'));
    }

    // Save the type.
    biblio_type_save($entity);
    $this
      ->complete($entity, $row);
    return array(
      $entity->type,
    );
  }

  /**
   * Give handlers a shot at modifying the object (or taking additional action)
   * after saving it.
   *
   * @param $entity
   *   OGMembership object to build. This is the complete object after
   *   saving.
   * @param $source_row
   *   Raw source data object - passed through to complete handlers.
   */
  public function complete($entity, stdClass $row) {

    // We do nothing here but allow child classes to act.
    $migration = Migration::currentMigration();

    // Then call any complete handler for this specific Migration.
    if (method_exists($migration, 'complete')) {
      $migration
        ->complete($entity, $row);
    }
  }

  /**
   * Give handlers a shot at modifying the object before saving it.
   *
   * @param $entity
   *   OGMembership object to build. Prefilled with any fields mapped in
   *   the Migration.
   * @param $source_row
   *   Raw source data object - passed through to prepare handlers.
   */
  public function prepare($entity, stdClass $row) {

    // We do nothing here but allow child classes to act.
    $migration = Migration::currentMigration();

    // Then call any prepare handler for this specific Migration.
    if (method_exists($migration, 'prepare')) {
      $migration
        ->prepare($entity, $row);
    }
  }
  public function fields() {
    return array(
      'type' => 'The machine-readable name of this type.',
      'name' => 'The human-readable name of this type.',
      'description' => 'A brief description of this type.',
    );
  }

}

Members

Namesort descending Modifiers Type Description Overrides
MigrateDestination::$numCreated protected property Maintain stats on the number of destination objects created or updated.
MigrateDestination::$numUpdated protected property
MigrateDestination::getCreated public function
MigrateDestination::getUpdated public function
MigrateDestination::resetStats public function Reset numCreated and numUpdated back to 0.
MigrateDestination::__construct public function Null constructor 7
MigrateDestinationBiblioType::complete public function Give handlers a shot at modifying the object (or taking additional action) after saving it.
MigrateDestinationBiblioType::fields public function Derived classes must implement fields(), returning a list of available destination fields. Overrides MigrateDestination::fields
MigrateDestinationBiblioType::getKeySchema public static function
MigrateDestinationBiblioType::import public function Import a biblio type. Overrides MigrateDestination::import
MigrateDestinationBiblioType::prepare public function Give handlers a shot at modifying the object before saving it.
MigrateDestinationBiblioType::rollback public function Delete a biblio type.
MigrateDestinationBiblioType::__toString public function Derived classes must implement __toString(). Overrides MigrateDestination::__toString