You are here

public static function CommonHookHandler::hookCron in Node expire 7.2

Implements hook_cron().

1 call to CommonHookHandler::hookCron()
node_expire_cron in ./node_expire.module
Implements hook_cron().

File

src/Module/Hook/CommonHookHandler.php, line 23
CommonHookHandler class.

Class

CommonHookHandler
CommonHookHandler class.

Namespace

Drupal\node_expire\Module\Hook

Code

public static function hookCron() {
  $handle_content_expiry = ConfigHandler::getHandleContentExpiry();
  if ($handle_content_expiry != 2) {
    $result = DbHandler::selectExpired();
  }
  else {
    $result = DbHandler::selectExpiredNonFlagged();
  }

  // $nids = array();
  // Create NodeTypesConfigHandler once for whole cycle.
  $config_handler = new NodeTypesConfigHandler();
  foreach ($result as $record) {

    // Try to handle the record.
    try {

      // $nids[] = $record->nid;
      $node_type = $record->type;
      $action_type = $config_handler
        ->getActionType($node_type);
      $nid = $record->nid;
      DbHandler::setExpired($nid);

      // $node = node_load($record->nid);
      // rules_invoke_event('node_expired', $node);
      ActionsHandler::doAction($action_type, $nid);
    } catch (\Exception $e) {

      // TODO: Add configurable logging.
    }
  }
}