class SimplenewsSpool in Simplenews 7
Same name and namespace in other branches
- 7.2 includes/simplenews.source.inc \SimplenewsSpool
Simplenews Spool implementation.
Hierarchy
- class \SimplenewsSpool implements SimplenewsSpoolInterface
Expanded class hierarchy of SimplenewsSpool
Related topics
File
- includes/
simplenews.source.inc, line 246 - Contains SimplenewsSource interface and implementations.
View source
class SimplenewsSpool implements SimplenewsSpoolInterface {
/**
* Array with mail spool rows being processed.
*
* @var array
*/
protected $spool_list;
/**
* Array of the processed mail spool rows.
*/
protected $processed = array();
/**
* Implements SimplenewsSpoolInterface::_construct($spool_list);
*/
public function __construct($spool_list) {
$this->spool_list = $spool_list;
}
/**
* Implements SimplenewsSpoolInterface::nextSource();
*/
public function nextSource() {
// Get the current mail spool row and update the internal pointer to the
// next row.
$return = each($this->spool_list);
// If we're done, return false.
if (!$return) {
return FALSE;
}
$spool_data = $return['value'];
// Store this spool row as processed.
$this->processed[$spool_data->msid] = $spool_data;
$node = node_load($spool_data->nid);
if (!$node) {
// If node the load failed, set the processed status done and proceed with
// the next mail.
$this->processed[$spool_data->msid]->result = array(
'status' => SIMPLENEWS_SPOOL_DONE,
'error' => TRUE,
);
return $this
->nextSource();
}
if ($spool_data->data) {
$subscriber = $spool_data->data;
}
else {
$subscriber = simplenews_subscriber_load_by_mail($spool_data->mail);
}
if (!$subscriber) {
// If loading the subscriber failed, set the processed status done and
// proceed with the next mail.
$this->processed[$spool_data->msid]->result = array(
'status' => SIMPLENEWS_SPOOL_DONE,
'error' => TRUE,
);
return $this
->nextSource();
}
$source_class = $this
->getSourceImplementation($spool_data);
$source = new $source_class($node, $subscriber);
// Set which node is actually used. In case of a translation set, this might
// not be the same node.
$this->processed[$spool_data->msid]->actual_nid = $source
->getNode()->nid;
return $source;
}
/**
* Implements SimplenewsSpoolInterface::getProcessed();
*/
function getProcessed() {
$processed = $this->processed;
$this->processed = array();
return $processed;
}
/**
* Return the Simplenews source implementation for the given mail spool row.
*/
protected function getSourceImplementation($spool_data) {
return variable_get('simplenews_source', 'SimplenewsSourceNode');
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
SimplenewsSpool:: |
protected | property | Array of the processed mail spool rows. | |
SimplenewsSpool:: |
protected | property | Array with mail spool rows being processed. | |
SimplenewsSpool:: |
function |
Implements SimplenewsSpoolInterface::getProcessed(); Overrides SimplenewsSpoolInterface:: |
||
SimplenewsSpool:: |
protected | function | Return the Simplenews source implementation for the given mail spool row. | |
SimplenewsSpool:: |
public | function |
Implements SimplenewsSpoolInterface::nextSource(); Overrides SimplenewsSpoolInterface:: |
|
SimplenewsSpool:: |
public | function |
Implements SimplenewsSpoolInterface::_construct($spool_list); Overrides SimplenewsSpoolInterface:: |