Projet

Général

Profil

Paste
Télécharger (1,32 ko) Statistiques
| Branche: | Révision:

root / drupal7 / sites / all / modules / pathauto / pathauto.migrate.inc @ d719f12f

1
<?php
2

    
3
/**
4
 * @file
5
 * Support for the Pathauto module.
6
 */
7

    
8
/**
9
 * Field handler.
10
 */
11
class PathautoMigrationHandler extends MigrateDestinationHandler {
12
  public function __construct() {
13
    $this->registerTypes(array('entity'));
14
  }
15

    
16
  /**
17
   * Make the destination field visible.
18
   */
19
  public function fields() {
20
    return array(
21
      'pathauto' => t('Pathauto: Perform aliasing (set to 0 to prevent alias generation during migration'),
22
    );
23
  }
24

    
25
  public function prepare($entity, stdClass $row) {
26
    if (isset($entity->pathauto)) {
27
      if (!isset($entity->path)) {
28
        $entity->path = array();
29
      }
30
      elseif (is_string($entity->path)) {
31
        // If MigratePathEntityHandler->prepare() hasn't run yet, support
32
        // the alias (set as $entity->path as a string) being formatted properly
33
        // in the path alias array.
34
        $path = $entity->path;
35
        $entity->path = array();
36
        $entity->path['alias'] = $path;
37
      }
38
      $entity->path['pathauto'] = $entity->pathauto;
39
      if (!isset($entity->path['alias'])) {
40
        $entity->path['alias'] = '';
41
      }
42
      unset($entity->pathauto);
43
    }
44
  }
45
}
46

    
47
/*
48
 * Implementation of hook_migrate_api().
49
 */
50
function pathauto_migrate_api() {
51
  $api = array(
52
    'api' => 2,
53
    'destination handlers' => array('PathautoMigrationHandler'),
54
  );
55
  return $api;
56
}