class OgMigrateAddFields in Organic groups 7.2
@file Add OG related fields to group and group-content node-types.
Hierarchy
- class \MigrationBase
- class \OgMigrateAddFields
Expanded class hierarchy of OgMigrateAddFields
4 string references to 'OgMigrateAddFields'
- OgMigrate7000TestCase::setUp in ./
og.test - Overrides DrupalWebTestCase::setUp() for upgrade testing.
- OgMigrateGroup::__construct in includes/
migrate/ 7000/ og_group.inc - General initialization of a Migration object.
- OgMigrateOgurRoles::__construct in includes/
migrate/ 7000/ og_ogur_roles.migrate.inc - Override constructor from Migration class.
- og_migrate_api in ./
og.module - Implements hook_migrate_api().
File
- includes/
migrate/ 7000/ og_add_fields.inc, line 8 - Add OG related fields to group and group-content node-types.
View source
class OgMigrateAddFields extends MigrationBase {
public function __construct($arguments = array()) {
parent::__construct($arguments);
$this->description = t('Add OG related fields to group and group-content node-types.');
$this->enabled = !$this
->isComplete();
}
public function isComplete() {
return !variable_get('og_7000_add_field', FALSE);
}
/**
* Create group, group-audience and group description fields.
*/
public function import() {
og_create_field(OG_AUDIENCE_FIELD, 'user', 'user');
foreach (node_type_get_types() as $type) {
// Check if the variable exists.
if ($type_usage = variable_get('og_content_type_usage_' . $type->type)) {
switch ($type_usage) {
case 'group':
$content_type['group'][] = $type->type;
break;
case 'group_post_standard':
case 'group_post_wiki':
// The type of the group content is now determined via the
// group permissions. We only care about adding the group content
// fields to the node.
$content_type['group content'][] = $type->type;
break;
}
}
}
if ($content_type) {
// Add group and group content fields to content types.
$field_names = array(
'group' => OG_GROUP_FIELD,
'group content' => OG_AUDIENCE_FIELD,
);
foreach ($field_names as $key => $field_name) {
$content_type += array(
$key => array(),
);
foreach ($content_type[$key] as $type) {
og_create_field($field_name, 'node', $type);
if ($key == 'group') {
if (!field_info_field('og_description')) {
$field = array(
'field_name' => 'og_description',
'type' => 'text',
'entity_types' => array(
'node',
),
'cardinality' => 1,
);
$field = field_create_field($field);
}
if (!field_info_instance('node', 'og_description', $type)) {
// Create the "description" field for the bundle.
$instance = array(
'field_name' => 'og_description',
'bundle' => $type,
'entity_type' => 'node',
'label' => t('Group description'),
'description' => t('This is description of the group.'),
);
field_create_instance($instance);
// Delete the OG6 variable.
variable_del('og_content_type_usage_' . $type);
}
}
}
}
}
// Delete the field that indicates we still need to add fields.
variable_del('og_7000_add_field');
return MigrationBase::RESULT_COMPLETED;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
MigrationBase:: |
protected | property | Arguments configuring a migration. | |
MigrationBase:: |
protected | property | A time limit in seconds appropriate to be used in a batch import. Defaults to 240. | |
MigrationBase:: |
protected static | property | Track the migration currently running, so handlers can easily determine it without having to pass a Migration object everywhere. | |
MigrationBase:: |
protected | property | List of other Migration classes which should be imported before this one. E.g., a comment migration class would typically have node and user migrations as dependencies. | |
MigrationBase:: |
protected | property | Detailed information describing the migration. | |
MigrationBase:: |
protected | property | Any module hooks which should be disabled during migration processes. | |
MigrationBase:: |
protected static | property | Name of a function for displaying feedback. It must take the message to display as its first argument, and a (string) message type as its second argument (see drush_log()). | |
MigrationBase:: |
protected static | property | ||
MigrationBase:: |
protected | property | Disabling a migration prevents it from running with --all, or individually without --force | |
MigrationBase:: |
protected | property | A migration group object, used to collect related migrations. | |
MigrationBase:: |
protected static | property | Have we already warned about obsolete constructor argumentss on this request? | |
MigrationBase:: |
protected | property | If provided, an URL for an issue tracking system containing :id where the issue number will go (e.g., 'http://example.com/project/ticket/:id'). | |
MigrationBase:: |
protected | property | Whether to maintain a history of migration processes in migrate_log | |
MigrationBase:: |
protected | property | Primary key of the current history record (inserted at the beginning of a process, to be updated at the end) | |
MigrationBase:: |
protected | property | The machine name of this Migration object, derived by removing the 'Migration' suffix from the class name. Used to construct default map/message table names, displayed in drush migrate-status, key to migrate_status table... | |
MigrationBase:: |
protected | property | An array to track 'mail_system' variable if disabled. | |
MigrationBase:: |
protected | property | The PHP memory_limit expressed in bytes. | |
MigrationBase:: |
protected | property | The fraction of the memory limit at which an operation will be interrupted. Can be overridden by a Migration subclass if one would like to push the envelope. Defaults to 85%. | |
MigrationBase:: |
protected | property | Save options passed to current operation | |
MigrationBase:: |
protected | property | If we set an error handler (during import), remember the previous one so it can be restored. | |
MigrationBase:: |
protected | property | Indicates that we are processing a rollback or import - used to avoid excess writes in endProcess() | |
MigrationBase:: |
protected static | property | Track whether or not we've already displayed an encryption warning | |
MigrationBase:: |
protected | property | When the current operation started. | |
MigrationBase:: |
protected | property | Are we importing, rolling back, or doing nothing? | |
MigrationBase:: |
protected | property | MigrateTeamMember objects representing people involved with this migration. | |
MigrationBase:: |
protected | property | The PHP max_execution_time. | |
MigrationBase:: |
protected | property | The fraction of the time limit at which an operation will be interrupted. Can be overridden by a Migration subclass if one would like to push the envelope. Defaults to 90%. | |
MigrationBase:: |
protected | property | Number of "items" processed in the current migration process (whatever that means for the type of process) | |
MigrationBase:: |
public | function | ||
MigrationBase:: |
public | function | ||
MigrationBase:: |
public | function | ||
MigrationBase:: |
protected | function | Begin a process, ensuring only one process can be active at once on a given migration. | 1 |
MigrationBase:: |
public static | function | ||
MigrationBase:: |
public static | function | Decrypt an incoming value. | |
MigrationBase:: |
public static | function | Make sure any arguments we want to be decrypted get decrypted. | |
MigrationBase:: |
protected | function | Reports whether all (hard) dependencies have completed migration | |
MigrationBase:: |
public static | function | Deregister a migration - remove all traces of it from the database (without touching any content which was created by this migration). | 1 |
MigrationBase:: |
public | function | Disables mail system to prevent emails from being sent during migrations. | |
MigrationBase:: |
public static | function | Output the given message appropriately (drush_print/drupal_set_message/etc.) | |
MigrationBase:: |
public static | function | Encrypt an incoming value. Detects for existence of the Drupal 'Encrypt' module. | |
MigrationBase:: |
public static | function | Make sure any arguments we want to be encrypted get encrypted. | |
MigrationBase:: |
public | function | End a rollback or import process, releasing the semaphore. Note that it must be public to be callable as the shutdown function. | 1 |
MigrationBase:: |
public | function | Custom PHP error handler. TODO: Redundant with hook_watchdog? | |
MigrationBase:: |
protected | function | The migration machine name is stored in the arguments. | 1 |
MigrationBase:: |
public | function | ||
MigrationBase:: |
public | function | ||
MigrationBase:: |
public | function | ||
MigrationBase:: |
public | function | ||
MigrationBase:: |
public | function | ||
MigrationBase:: |
public | function | ||
MigrationBase:: |
public | function | ||
MigrationBase:: |
public | function | Fetch the current highwater mark for updated content. | |
MigrationBase:: |
public static | function | Return the single instance of the given migration. | |
MigrationBase:: |
public | function | ||
MigrationBase:: |
public | function | ||
MigrationBase:: |
public | function | Retrieve the last time an import operation completed successfully. | |
MigrationBase:: |
public | function | Retrieve the last throughput for current Migration (items / minute). | |
MigrationBase:: |
public | function | ||
MigrationBase:: |
public | function | Get human readable name for a message constant. | |
MigrationBase:: |
public | function | ||
MigrationBase:: |
public | function | ||
MigrationBase:: |
public | function | Check the current status of a migration. | |
MigrationBase:: |
public | function | ||
MigrationBase:: |
public | function | ||
MigrationBase:: |
public | function | Takes an Exception object and both saves and displays it, pulling additional information on the location triggering the exception. | |
MigrationBase:: |
public | function | Returns an array of the migration's dependencies that are incomplete. | |
MigrationBase:: |
public static | function | 1 | |
MigrationBase:: |
protected static | function | Given only a class name, derive a machine name (the class name with the "Migration" suffix, if any, removed). | |
MigrationBase:: |
protected | function | Test whether we've exceeded the desired memory threshold. If so, output a message. | |
MigrationBase:: |
constant | Message types to be passed to saveMessage() and saved in message tables. MESSAGE_INFORMATIONAL represents a condition that did not prevent the operation from succeeding - all others represent different severities of conditions resulting in a source… | ||
MigrationBase:: |
constant | |||
MigrationBase:: |
constant | |||
MigrationBase:: |
constant | |||
MigrationBase:: |
public | function | Perform an operation during the import phase | |
MigrationBase:: |
public | function | Perform an operation during the rollback phase. | |
MigrationBase:: |
public static | function | Register a new migration process in the migrate_status table. This will generally be used in two contexts - by the class detection code for static (one instance per class) migrations, and by the module implementing dynamic (parameterized class)… | 1 |
MigrationBase:: |
public | function | Reset the status of the migration to IDLE (to be used when the status gets stuck, e.g. if a process core-dumped) | |
MigrationBase:: |
public | function | Restores the original saved mail system for migrations that require it. | |
MigrationBase:: |
constant | Codes representing the result of a rollback or import process. | ||
MigrationBase:: |
constant | |||
MigrationBase:: |
constant | |||
MigrationBase:: |
constant | |||
MigrationBase:: |
constant | |||
MigrationBase:: |
constant | |||
MigrationBase:: |
protected | function | Save the highwater mark for this migration (but not when using an idlist). | |
MigrationBase:: |
public | function | Saves the current mail system, or set a system default if there is none. | |
MigrationBase:: |
public | function | Default to printing messages, but derived classes are expected to save messages indexed by current source ID. | 1 |
MigrationBase:: |
public | function | ||
MigrationBase:: |
public | function | Set the PHP time limit. This method may be called from batch callbacks before calling the processImport method. | |
MigrationBase:: |
public | function | ||
MigrationBase:: |
public static | function | ||
MigrationBase:: |
public | function | ||
MigrationBase:: |
public | function | ||
MigrationBase:: |
public | function | ||
MigrationBase:: |
public | function | ||
MigrationBase:: |
public | function | ||
MigrationBase:: |
public static | function | Initialize static members, before any class instances are created. | |
MigrationBase:: |
constant | |||
MigrationBase:: |
constant | Codes representing the current status of a migration, and stored in the migrate_status table. | ||
MigrationBase:: |
constant | |||
MigrationBase:: |
constant | |||
MigrationBase:: |
constant | |||
MigrationBase:: |
public | function | Signal that any current import or rollback process should end itself at the earliest opportunity | |
MigrationBase:: |
protected | function | Test whether we're approaching the PHP time limit. | |
MigrationBase:: |
protected | function | Test whether we've exceeded the designated time limit. | |
MigrationBase:: |
public static | function | Convert an incoming string (which may be a UNIX timestamp, or an arbitrarily-formatted date/time string) to a UNIX timestamp. | |
OgMigrateAddFields:: |
public | function | Create group, group-audience and group description fields. | |
OgMigrateAddFields:: |
public | function |
Reports whether this migration process is complete. For a Migration, for
example, this would be whether all available source rows have been
processed. Other MigrationBase classes will need to return TRUE/FALSE
appropriately. Overrides MigrationBase:: |
|
OgMigrateAddFields:: |
public | function |
Construction of a MigrationBase instance. Overrides MigrationBase:: |