You are here

configuration.install in Configuration Management 7

Same filename and directory in other branches
  1. 6 configuration.install
  2. 7.2 configuration.install

File

configuration.install
View source
<?php

/**
 * Implements hook_schema().
 */
function configuration_schema() {
  $schema['config_export'] = array(
    'description' => 'The table that holds the status of what is being tracked in configuration management.',
    'fields' => array(
      'cid' => array(
        'description' => 'The primary identifier for a configuration.',
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'name' => array(
        'type' => 'varchar',
        'length' => '128',
        'default' => '',
        'not null' => TRUE,
        'description' => 'The unique name of the configuration item. This is the primary field configurations are loaded from.',
      ),
      'owner' => array(
        'type' => 'varchar',
        'length' => '32',
        'default' => '',
        'not null' => TRUE,
        'description' => 'The module name that owns the configuration item.',
      ),
      'status' => array(
        'type' => 'int',
        'not null' => TRUE,
        // Set the default to ENTITY_CUSTOM without using the constant as it is
        // not safe to use it at this point.
        'default' => 0x0,
        'size' => 'tiny',
        'description' => 'The exportable status of a configuration.',
      ),
      'hash' => array(
        'type' => 'char',
        'not null' => TRUE,
        'default' => '',
        'length' => '32',
        'description' => 'The last hash status of a configuration.',
      ),
      'parent' => array(
        'type' => 'varchar',
        'length' => '256',
        'default' => '',
        'description' => 'Holds the name of parent configs',
      ),
      'dependencies' => array(
        'type' => 'text',
        'size' => 'normal',
        'description' => 'Holds a serialized array of module dependencies',
      ),
    ),
    'primary key' => array(
      'cid',
    ),
    'indexes' => array(
      'plugin' => array(
        'owner',
      ),
    ),
  );
  $schema['cache_configuration'] = drupal_get_schema_unprocessed('system', 'cache');
  return $schema;
}

/**
 * Implements hook_install().
 */
function configuration_install() {
  $directory = variable_get('configuration_config_path', conf_path() . '/files/config');
  if (!is_dir($directory) && !drupal_mkdir($directory, NULL, TRUE)) {

    // If the directory does not exists and cannot be created.
    drupal_set_message(st('The directory %directory does not exist and could not be created.', array(
      '%directory' => $directory,
    )), 'error');
    watchdog('file system', 'The directory %directory does not exist and could not be created.', array(
      '%directory' => $directory,
    ), WATCHDOG_ERROR);
  }
  if (is_dir($directory) && !is_writable($directory) && !drupal_chmod($directory)) {

    // If the directory is not writable and cannot be made so.
    drupal_set_message(st('The directory %directory exists but is not writable and could not be made writable.', array(
      '%directory' => $directory,
    )), 'error');
    watchdog('file system', 'The directory %directory exists but is not writable and could not be made writable.', array(
      '%directory' => $directory,
    ), WATCHDOG_ERROR);
  }
  elseif (is_dir($directory)) {
    file_create_htaccess($directory);
  }
}

/**
 * Implements hook_uninstall().
 */
function configuration_uninstall() {
  $config_dir = variable_get('configuration_config_path', conf_path() . '/files/config');
  foreach (glob($config_dir . "/*") as $filename) {
    unlink($filename);
  }
  if (is_file($config_dir . '/.htaccess')) {
    unlink($config_dir . '/.htaccess');
  }
  rmdir($config_dir);
  variable_del('configuration_config_path');
}

Functions