class MerciContentTypesMigrateSource in MERCI (Manage Equipment Reservations, Checkout and Inventory) 7.3
Hierarchy
- class \MigrateSource implements \Iterator
- class \MigrateSourceSQL
Expanded class hierarchy of MerciContentTypesMigrateSource
File
- merci_migrate/
merci_item_display.inc, line 42
View source
class MerciContentTypesMigrateSource extends MigrateSourceSQL {
protected $merci_types;
protected $current_type;
// Your constructor will initialize any parameters to your migration. It's
// important to pass through the options, so general options such as
// cache_counts will work.
public function __construct(array $options = array()) {
$fields = array(
'type' => t('Type'),
'merci_type_setting' => t('Type Setting'),
'merci_max_hours_per_reservation' => t('Max hours'),
'merci_allow_overnight' => t('Allow overnight'),
'merci_allow_weekends' => t('Allow weekends'),
'merci_late_fee_per_hour' => t('late fee/hour'),
'merci_rate_per_hour' => t('rate/hour'),
'merci_fee_free_hours' => t('fee free hours'),
'merci_active_status' => t('Active status'),
'merci_spare_items' => t('Spare items'),
'merci_min_cancel_hours' => t('Minimum cancelation hours'),
'merci_autocheckout' => t('Auto checkout'),
'merci_autocheckin' => t('Auto checkin'),
'merci_selfcheckout' => t('Self checkout'),
'merci_grouping' => t('Item grouping'),
'merci_auto_assign_bucket_item' => t('Auto assign bucket'),
);
$query = db_select('merci_node_type', 'mt')
->condition('merci_type_setting', 'disabled', '<>')
->fields('mt', array_keys($fields));
$table_alias = $query
->join('node_type', 'nt', 'nt.type = mt.type');
$query
->fields('nt', array(
'name',
'description',
));
parent::__construct($query, array(), NULL, $options);
}
/**
* Downloads the next set of data from the source database.
*/
protected function getSkus($merci_type) {
$query = new EntityFieldQuery();
$entities = $query
->entityCondition('entity_type', 'node')
->propertyCondition('type', $merci_type->type)
->propertyCondition('status', 1)
->execute();
if ($entities) {
$skus = array();
$ids = array_keys($entities['node']);
$products = node_load_multiple($ids);
foreach ($products as $item) {
//$skus[] = $product->title;
$product = commerce_product_load_by_sku($item->title);
$skus[] = $product->product_id;
}
return $skus;
}
else {
return NULL;
}
}
/**
* Implementation of MigrateSource::getNextRow().
*
* @return object
*/
public function getNextRow() {
$row = parent::getNextRow();
if ($row) {
$row->skus = $this
->getSkus($row);
$row->type_name = $row->name;
$grouping = $row->merci_type_setting == 'resource' ? $row->type_name : t('Buckets');
$tid = variable_get('merci_grouping_' . $row->type, 0);
if ($tid) {
$term = taxonomy_term_load($tid);
if ($term) {
$grouping = $term->name;
}
}
$row->merci_item_grouping = $grouping;
}
return $row;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
MerciContentTypesMigrateSource:: |
protected | property | ||
MerciContentTypesMigrateSource:: |
protected | property | ||
MerciContentTypesMigrateSource:: |
public | function |
Implementation of MigrateSource::getNextRow(). Overrides MigrateSourceSQL:: |
|
MerciContentTypesMigrateSource:: |
protected | function | Downloads the next set of data from the source database. | |
MerciContentTypesMigrateSource:: |
public | function |
Simple initialization. Overrides MigrateSourceSQL:: |
|
MigrateSource:: |
protected | property | The MigrateMap class for the current migration. | |
MigrateSource:: |
protected | property | The Migration class currently invoking us, during rewind() and next(). | |
MigrateSource:: |
protected | property | Whether this instance should cache the source count. | |
MigrateSource:: |
protected | property | Key to use for caching counts. | |
MigrateSource:: |
protected | property | The primary key of the current row | |
MigrateSource:: |
protected | property | The current row from the quey | |
MigrateSource:: |
protected | property | Information on the highwater mark for the current migration, if any. | |
MigrateSource:: |
protected | property | List of source IDs to process. | |
MigrateSource:: |
protected | property | By default, next() will directly read the map row and add it to the data row. A source plugin implementation may do this itself (in particular, the SQL source can incorporate the map table into the query) - if so, it should set this TRUE so we… | |
MigrateSource:: |
protected | property | Used in the case of multiple key sources that need to use idlist. | |
MigrateSource:: |
protected | property | Number of rows intentionally ignored (prepareRow() returned FALSE) | |
MigrateSource:: |
protected | property | The highwater mark at the beginning of the import operation. | |
MigrateSource:: |
protected | property | Whether this instance should not attempt to count the source. | |
MigrateSource:: |
protected | property | If TRUE, we will maintain hashed source rows to determine whether incoming data has changed. | |
MigrateSource:: |
public | function | Return a count of available source records, from the cache if appropriate. Returns -1 if the source is not countable. | |
MigrateSource:: |
public | function | Implementation of Iterator::current() - called when entering a loop iteration, returning the current row | |
MigrateSource:: |
protected | function | Determine whether this row has changed, and therefore whether it should be processed. | |
MigrateSource:: |
public | function | ||
MigrateSource:: |
public | function | ||
MigrateSource:: |
public | function | ||
MigrateSource:: |
protected | function | Generate a hash of the source row. | 3 |
MigrateSource:: |
public | function | Implementation of Iterator::key - called when entering a loop iteration, returning the key of the current row. It must be a scalar - we will serialize to fulfill the requirement, but using getCurrentKey() is preferable. | |
MigrateSource:: |
public | function | Implementation of Iterator::next() - subclasses of MigrateSource should implement getNextRow() to retrieve the next valid source rocord to process. | |
MigrateSource:: |
protected | function | Give the calling migration a shot at manipulating, and possibly rejecting, the source row. | |
MigrateSource:: |
public | function | Reset numIgnored back to 0. | |
MigrateSource:: |
public | function | Implementation of Iterator::rewind() - subclasses of MigrateSource should implement performRewind() to do any class-specific setup for iterating source records. | |
MigrateSource:: |
public | function | Implementation of Iterator::valid() - called at the top of the loop, returning TRUE to process the loop and FALSE to terminate it | |
MigrateSourceSQL:: |
protected | property | Current data batch. | |
MigrateSourceSQL:: |
protected | property | Number of records to fetch from the database during each batch. A value of zero indicates no batching is to be done. | |
MigrateSourceSQL:: |
protected | property | List of available source fields. | |
MigrateSourceSQL:: |
protected | property | Whether, in the current iteration, we have reached the highwater mark. | |
MigrateSourceSQL:: |
protected | property | If the map is a MigrateSQLMap, and the table is compatible with the source query, we can join directly to the map and make things much faster and simpler. | |
MigrateSourceSQL:: |
protected | property |
Number of eligible rows processed so far (used for itemlimit checking). Overrides MigrateSource:: |
|
MigrateSourceSQL:: |
protected | property | The SQL query objects from which to obtain data, and counts of data. | |
MigrateSourceSQL:: |
protected | property | The result object from executing the query - traversed to process the incoming data. | |
MigrateSourceSQL:: |
protected | property | Whether this source is configured to use a highwater mark, and there is a highwater mark present to use. | |
MigrateSourceSQL:: |
public | function | Return a count of all available source records. | |
MigrateSourceSQL:: |
public | function |
Returns a list of fields available to be mapped from the source query. Overrides MigrateSource:: |
|
MigrateSourceSQL:: |
protected | function | Downloads the next set of data from the source database. | |
MigrateSourceSQL:: |
public static | function | Return an options array for PDO sources. | |
MigrateSourceSQL:: |
public | function | Implementation of MigrateSource::performRewind(). | |
MigrateSourceSQL:: |
public | function | Return a reference to the base query, in particular so Migration classes can add conditions/joins/etc to the query for a source defined in a base class. | |
MigrateSourceSQL:: |
public | function | ||
MigrateSourceSQL:: |
public | function | Return a string representing the source query. |