You are here

function ctools_configuration_check in Configuration Management 7

File

includes/configuration.ctools.inc, line 361

Code

function ctools_configuration_check($identifier) {

  // Set a static variable that we can access across this request.
  $from_activestore =& drupal_static('configuration_from_activestore');

  // The component name is the name of the function that called this function
  // after the string configuration_check_<component>
  $backtrace = @debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
  $component = substr($backtrace[1]['function'], strlen('configuration_check_'));

  // Load the current configuration file on disk
  $info = _ctools_configuration_get_info();
  if (file_exists('config://configuration.' . $component . '.inc')) {

    // Page Manager has it's export callback in a file that is not autoloaded.
    // PM also doesn not use the export variable, we have to set it here.
    // @todo: Come up with a cleaner way to include dependent files.
    if ($component == 'page_manager_pages') {
      ctools_include('page', 'page_manager', 'plugins/tasks');
      $export =& $pages;
    }
    include_once drupal_realpath('config://configuration.' . $component . '.inc');

    // Export just the field we're tracking.
    module_load_include('inc', 'configuration', 'configuration.export');
    $data = ctools_component_configuration_export_options($component);

    // Export the field we just saved and evaluate the export to $export
    $code = ctools_component_configuration_export_render($component, 'configuration', array(
      $identifier,
    ));
    eval(array_pop($code));
    $export_code = call_user_func('configuration_' . $info[$component]['default_hook']);

    // If this was the previous configuration in activestore don't mark this as changed.
    $config = configuration_get_configuration();

    // If the activestore doesn't exist it is most likely because this configuration
    // only exists in code.
    if (empty($export)) {
      configuration_set_status($component, $identifier, CONFIGURATION_TRACKED_DATASTORE_ONLY);
    }

    /**
     * @todo: There is a bug with an object being attached to views when
     * exporting. Haven't been able to track down where this is coming from so
     * I'm just going to unset it for now.
     */
    if ($component == 'views_view') {
      foreach ($export as &$view) {
        if (property_exists($view, 'localization_plugin')) {
          unset($view->localization_plugin);
        }
      }
    }
    configuration_update_component_status($component, $identifier, $export, $export_code, $from_activestore);
  }
}