You are here

class DomainNodeHandler in Domain Access 7.3

Migration class for importing Drupal nodes.

In your migration class, there are two field mappings you may set.

  • domain_site is a binary flag indicating that a node is assigned to "all affiliates" in your installation.
  • domains is a domain_id string or array of domain ids (either numeric or machine_name, and you may mix the two) that indicate the domain(s) the content should be published to.

Note that failure to set these values explicitly will mean they are set automatically. The domain_site value is configurable per content type. The domains array will be populated with your default domain, if it exists.

Hierarchy

Expanded class hierarchy of DomainNodeHandler

1 string reference to 'DomainNodeHandler'
domain_migrate_api in ./domain.module

File

./domain.migrate.inc, line 247
Support for domains in core Drupal objects

View source
class DomainNodeHandler extends MigrateDestinationHandler {
  public function __construct() {
    $this
      ->registerTypes(array(
      'node',
    ));
  }
  public function fields() {
    $fields = array(
      'domain_site' => t('Domain: all affiliates'),
      'domains' => t('Domain: assigned domains'),
    );
    return $fields;
  }
  public function prepare($node, stdClass $row) {
    $domains = array();

    // If not set, be sure that we aren't updating an existing record.
    if (!empty($node->nid) && empty($node->domains)) {
      $nodes[$node->nid] = $node;
      domain_node_load($nodes, array());
    }

    // If set, ensure domains exist.
    if (isset($node->domains)) {
      $node->domains = (array) $node->domains;
      foreach ($node->domains as $id) {
        if ($domain = domain_load($id)) {
          $domains[$domain['domain_id']] = $domain['domain_id'];
        }
        if ($domain = domain_machine_name_load($id)) {
          $domains[$domain['domain_id']] = $domain['domain_id'];
        }
      }
    }

    // If empty, assign to the default domain. Note that domain_site can be
    // set automatically if not added by the migration.
    if (empty($domains) && ($default = domain_default_id())) {
      $domains[$default] = $default;
    }
    $node->domains = $domains;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
DomainNodeHandler::fields public function
DomainNodeHandler::prepare public function
DomainNodeHandler::__construct public function Overrides MigrateHandler::__construct
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