GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — 7.x-1.x ( 94dab8...029788 )
by Devin
03:44
created

DFSlideshowFPP   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 67
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 3
Bugs 0 Features 1
Metric Value
c 3
b 0
f 1
dl 0
loc 67
rs 10
wmc 5
lcom 0
cbo 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 48 2
A prepareRow() 0 14 3
1
<?php
2
3
/**
4
 * @file
5
 *  Migrations for Fieldable Panel Panes.
6
 */
7
8
class DFSlideshowFPP extends Migration {
9
10
  public function __construct($arguments) {
11
    parent::__construct($arguments);
12
    $this->description = t('Import Slideshow FPPs.');
13
14
    // Create a map object for tracking the relationships between source rows
15
    $this->map = new MigrateSQLMap($this->machineName,
16
      array(
17
        'UUID' => array(
18
          'type' => 'varchar',
19
          'length' => 36,
20
          'not null' => FALSE,
21
          'description' => 'The Universally Unique Identifier.',
22
        )
23
      ),
24
      array(
25
        'uuid' => array(
26
          'type' => 'varchar',
27
          'length' => 36,
28
          'not null' => FALSE,
29
          'description' => 'The Universally Unique Identifier.',
30
        )
31
      )
32
    );
33
34
    // Create a MigrateSource object.
35
    if (isset($arguments['path'])) {
36
      $import_path = $arguments['path'];
37
    }
38
    else {
39
      $import_path = drupal_get_path('module', 'df_tools_slideshow') . '/import/df_tools_slideshow.fpp.slideshow.csv';
40
    }
41
    $this->source = new MigrateSourceCSV($import_path, array(), array('header_rows' => 1));
42
    $this->destination = new MigrateDestinationFieldablePanelsPanes('slideshow', array('text_format' => 'raw_html'));
43
44
    $this->addFieldMapping('field_media', 'media_formatted');
45
    $this->addFieldMapping('field_media:file_replace')->defaultValue(FILE_EXISTS_REPLACE);
46
    $this->addFieldMapping('field_media:source_dir')->defaultValue(dirname($import_path) . '/images');
47
    $this->addFieldMapping('field_media:destination_file', 'filename');
48
49
    $this->addFieldMapping('field_title', 'title_formatted');
50
    $this->addFieldMapping('field_body', 'body_formatted');
51
52
    $this->addFieldMapping('title', 'Title');
53
    $this->addFieldMapping('uuid', 'UUID');
54
    $this->addFieldMapping('category', 'Category')->defaultValue('Reusable panes');
55
56
    $this->addFieldMapping('reusable', 'Reusable')->defaultValue(TRUE);
57
  }
58
59
  public function prepareRow($row) {
60
    $row->media_formatted = array();
61
    $row->title_formatted = array();
62
    $row->body_formatted = array();
63
    foreach ($row as $column => $value) {
64
      // Check to see if this is a slide field column
65
      if (strpos($column, 'Slide ') === 0) {
66
        // Slide columns are in the format "Slide <index> <Field>"
67
        $column = explode(' ', $column);
68
        $row->{strtolower($column[2]) . '_formatted'}[$column[1]] = $value;
69
      }
70
    }
71
    return TRUE;
72
  }
73
74
}
75