<?php
/**
 * @file
 * Code for the Panopoly Demo feature.
 */

include_once 'panopoly_demo.features.inc';

/**
 * Implements hook_menu_alter().
 */
function panopoly_demo_menu_alter(&$items) {
  $items['node']['page callback'] = 'drupal_goto';
  $items['node']['page arguments'] = array('demo');
}

/**
 * Implements hook_ctools_plugin_directory().
 */
function panopoly_demo_ctools_plugin_directory($module, $plugin) {
  return 'plugins/' . $plugin;
}

/**
 * Implements hook_link_alter(). 
 * 
 * This is a clever workaround for some notice errors that
 * we introduced in Panopoly Admin RC3. This function can be
 * removed with the next version of Panopoly. More information
 * is here - http://drupal.org/node/1838084
 */
function panopoly_demo_menu_link_alter(&$item) {
  if (empty($item['path'])) {
    $item['path'] = $item['link_path'];
  }
}

/**
 * Implements hook_migrate_api().
 */
function panopoly_demo_migrate_api() {
  $api = array(
    'api' => 2,
    'groups' => array(
      'panopoly_demo' => array(
        'title' => t('Panopoly Demo Content'),
      ),
    ),
    'migrations' => array(
      'PanopolyDemoNode' => array(
        'class_name' => 'PanopolyDemoNode',
        'group_name' => 'panopoly_demo',
      ),
      'PanopolyDemoMenu' => array(
        'class_name' => 'PanopolyDemoMenu',
        'group_name' => 'panopoly_demo',
      ),
    ),
  );
  return $api;
}
