function node_expire_cron in Node expire 8
Same name and namespace in other branches
- 5 node_expire.module \node_expire_cron()
- 6.2 node_expire.module \node_expire_cron()
- 6 node_expire.module \node_expire_cron()
- 7.2 node_expire.module \node_expire_cron()
- 7 node_expire.module \node_expire_cron()
Implements hook_cron().
File
- ./
node_expire.module, line 18 - Set a timer into your content, allowing you to perform customized actions.
Code
function node_expire_cron() {
$handle_content_expiry = \Drupal::config('node_expire.settings')
->get('node_expire_handle_content_expiry');
if ($handle_content_expiry != 2) {
$result = db_query('SELECT n.nid FROM {node} n
JOIN {node_expire} ne ON n.nid = ne.nid
WHERE ne.expire <= :ne_expire', array(
':ne_expire' => REQUEST_TIME,
));
}
else {
$result = db_query('SELECT n.nid FROM {node} n
JOIN {node_expire} ne ON n.nid = ne.nid
WHERE ne.expire <= :ne_expire AND ne.expired = 0', array(
':ne_expire' => REQUEST_TIME,
));
}
// $nids = array();
foreach ($result as $record) {
// $nids[] = $record->nid;
node_expire_set_expired($record->nid);
$node = \Drupal::entityManager()
->getStorage('node')
->load($record->nid);
rules_invoke_event('node_expired', $node);
}
}