You are here

public function MigratePathautoHandler::prepare in Migrate Extras 7.2

File

./pathauto.inc, line 31
Support for the Pathauto module.

Class

MigratePathautoHandler
Field handler.

Code

public function prepare($entity, stdClass $row) {
  if (isset($entity->pathauto)) {
    if (!isset($entity->path)) {
      $entity->path = array();
    }
    elseif (is_string($entity->path)) {

      // If MigratePathEntityHandler->prepare() hasn't run yet, support
      // the alias (set as $entity->path as a string) being formatted properly
      // in the path alias array.
      $path = $entity->path;
      $entity->path = array();
      $entity->path['alias'] = $path;
    }
    $entity->path['pathauto'] = $entity->pathauto;
    if (!isset($entity->path['alias'])) {
      $entity->path['alias'] = '';
    }
    unset($entity->pathauto);
  }
}