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 ( 34e25a...94dab8 )
by Devin
03:48
created

DFLandingNodes::__construct()   B

Complexity

Conditions 2
Paths 2

Size

Total Lines 29
Code Lines 18

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 2
eloc 18
nc 2
nop 1
dl 0
loc 29
rs 8.8571
c 2
b 0
f 0
1
<?php
2
3
/**
4
 * @file
5
 *  Migrations for Landing Nodes.
6
 */
7
8
class DFLandingNodes extends ImportBaseNodes {
9
10
  public function __construct($arguments) {
11
    parent::__construct($arguments);
12
    $this->description = t('Import Landing nodes.');
13
14
    // Our parent defines this, but since we have indeterminate csvcolumns "title" is no longer set, just "Title"
15
    $this->map = new MigrateSQLMap($this->machineName,
16
      array(
17
        'Title' => array(
18
          'type' => 'varchar',
19
          'length' => 255,
20
          'not null' => TRUE,
21
        ),
22
      ),
23
      MigrateDestinationNode::getKeySchema()
24
    );
25
26
    // Create a MigrateSource object.
27
    if (isset($arguments['path'])) {
28
      $import_path = $arguments['path'];
29
    }
30
    else {
31
      $import_path = drupal_get_path('module', 'df_tools_panelizer') . '/import/df_tools_panelizer.nodes.landing.csv';
32
    }
33
    $this->source = new MigrateSourceCSV($import_path, array(), array('header_rows' => 1));
34
    $this->destination = new MigrateDestinationNode('landing');
35
36
    $this->addFieldMapping('path', 'Path');
37
    $this->addFieldMapping('title', 'Title');
38
  }
39
40
  public function prepareRow($row) {
41
    // Check for columns that define region content
42
    foreach ($row as $key => $value) {
43
      // Set the value of this key to the exploded list of UUIDs
44
      if (strpos($key, 'region-') === 0) {
45
        $row->$key = explode(",", $value);
46
      }
47
    }
48
    return TRUE;
49
  }
50
51
  public function complete($entity, stdClass $row) {
52
    // Load the new node
53
    list($id) = entity_extract_ids('node', $entity);
54
    $node = node_load($id);
55
56
    // As each node is imported, add default Panels displays and Panels if necessary
57
    foreach ($row as $key => $value) {
0 ignored issues
show
Bug introduced by
The expression $row of type object<stdClass> is not traversable.
Loading history...
58
      // Check if this is a region column and that there are UUIDs set
59
      if (strpos($key, 'region-') === 0 && !empty($value)) {
60
        // Parse out the region name
61
        $location = str_replace('region-', '', $key);
62
63
        // Grab the display from the new Landing node
64
        $display = $node->panelizer['page_manager']->display;
65
66
        // Loop through each UUID in this region and add a new pane for this node
67
        foreach ($value as $uuid) {
68
          $pane = panels_new_pane('fieldable_panels_pane', 'uuid:' . $uuid, TRUE);
69
          // Check to see if any classy panel styles are included for this pane
70
          if (array_key_exists($uuid . '-style', $row) && $settings = json_decode($row->{$uuid . '-style'}, TRUE)) {
71
            // Add our default settings
72
            $settings['classy_panel_styles_flag'] = 'classy-panel-styles pane';
73
            $pane->style = array(
74
              'style' => 'classy_panel_styles:cps_default',
75
              'settings' => $settings
76
            );
77
          }
78
          // Add the pane to the display
79
          $display->add_pane($pane, $location);
80
          // Save the display
81
          $display = panels_save_display($display);
82
        }
83
84
        // Mark the Node as modified so that Panelizer is aware of our changes
85
        $node->panelizer['page_manager']->display_is_modified = TRUE;
86
      }
87
      // Check to see if a display setting needs to be changed
88
      elseif (strpos($key, 'display-') === 0) {
89
        // Parse out the display setting name
90
        $setting = str_replace('display-', '', $key);
91
92
        // Change the value for this display setting
93
        $node->panelizer['page_manager']->display->$setting = $value;
94
        // Mark the Node as modified so that Panelizer is aware of our changes
95
        $node->panelizer['page_manager']->display_is_modified = TRUE;
96
        panels_save_display($node->panelizer['page_manager']->display);
97
      }
98
      // Check to see if a panelizer settings needs to be changed
99
      elseif (strpos($key, 'panelizer-') === 0) {
100
        // Parse out the panelizer setting name
101
        $setting = str_replace('panelizer-', '', $key);
102
        $node->panelizer['page_manager']->$setting = $value;
103
      }
104
    }
105
106
    // If we've made changes, save the node
107
    if ($node->panelizer['page_manager']->display_is_modified == TRUE) {
108
      node_save($node);
109
    }
110
111
  }
112
113
}
114