You are here

public static function ActionsHandler::doAction in Node expire 7.2

Executes particular action with the node..

1 call to ActionsHandler::doAction()
CommonHookHandler::hookCron in src/Module/Hook/CommonHookHandler.php
Implements hook_cron().

File

src/Module/CommonExpire/Actions/ActionsHandler.php, line 21
ActionsHandler class.

Class

ActionsHandler
ActionsHandler class.

Namespace

Drupal\node_expire\Module\CommonExpire\Actions

Code

public static function doAction($action_type, $nid) {
  switch ($action_type) {
    case ActionTypeEnum::NONE:

      // Do nothing.
      break;
    case ActionTypeEnum::RULES_EVENT:
      if (module_exists('rules')) {
        $node = node_load($nid);
        rules_invoke_event('node_expired', $node);
      }
      else {
        throw new ExpireException(t('Module Rules is not installed.'));
      }
      break;
    case ActionTypeEnum::NODE_PUBLISH:
      NodeHelper::publishNode($nid);
      break;
    case ActionTypeEnum::NODE_UNPUBLISH:
      NodeHelper::unpublishNode($nid);
      break;
    case ActionTypeEnum::NODE_STICKY:
      NodeHelper::makeNodeSticky($nid);
      break;
    case ActionTypeEnum::NODE_UNSTICKY:
      NodeHelper::makeNodeUnsticky($nid);
      break;
    case ActionTypeEnum::NODE_PROMOTE_TO_FRONT:
      NodeHelper::promoteNode($nid);
      break;
    case ActionTypeEnum::NODE_REMOVE_FROM_FRONT:
      NodeHelper::unpromoteNode($nid);
      break;
    default:

      // Do nothing.
      break;
  }
}