class FormHookHelper in Node expire 7.2
FormHookHelper class.
Hierarchy
- class \Drupal\node_expire\Module\Hook\FormHookHelper
Expanded class hierarchy of FormHookHelper
1 file declares its use of FormHookHelper
- node_expire.module in ./
node_expire.module - Set a timer into your content, allowing you to perform customized actions.
File
- src/
Module/ Hook/ FormHookHelper.php, line 19 - FormHookHelper class.
Namespace
Drupal\node_expire\Module\HookView source
class FormHookHelper {
/**
* Implements hook_form_alter().
*/
public static function doFormNodeTypeFormAlterValidate(&$form, &$form_state) {
$node_expire =& $form_state['values']['node_expire_type_cfg_default'];
if (!empty($node_expire) and !strtotime($node_expire)) {
form_set_error('node_expire', t('This values should be in PHP <a href="http://www.php.net/strtotime" target="_blank">strtotime format</a>.'));
}
$node_expire_max =& $form_state['values']['node_expire_type_cfg_max'];
if (!empty($node_expire_max)) {
if (!strtotime($node_expire_max)) {
form_set_error('node_expire_max', t('This values should be in PHP <a href="http://www.php.net/strtotime" target="_blank">strtotime format</a>.'));
}
elseif (strtotime($node_expire) > strtotime($node_expire_max)) {
form_set_error('node_expire_max', t('This value cannot be earlier then the maximum value.'));
}
}
$node_expire_required =& $form_state['values']['node_expire_type_cfg_required'];
if (!empty($node_expire_required)) {
if (empty($node_expire)) {
form_set_error('node_expire', t('Default expiration date should be set with expiration date required.'));
}
}
}
/**
* Implements hook_form_alter().
*/
public static function doFormNodeTypeFormAlterSubmit(&$form, &$form_state) {
$ntypes = variable_get('node_expire_ntypes', array());
$handle_content_expiry = ConfigHandler::getHandleContentExpiry();
if ($handle_content_expiry != 0) {
$ntypes[$form_state['values']['type']]['enabled'] = $form_state['values']['node_expire_type_cfg_enabled'];
}
// TODO: replace ['node_expire'] => ['node_expire_default'],
// after that optimize.
$ntypes[$form_state['values']['type']]['default'] = TimestampUtils::dateStrToCfgDefault($form_state['values']['node_expire_type_cfg_default']);
$ntypes[$form_state['values']['type']]['max'] = TimestampUtils::dateStrToCfgDefault($form_state['values']['node_expire_type_cfg_max']);
$ntypes[$form_state['values']['type']]['required'] = $form_state['values']['node_expire_type_cfg_required'];
$ntypes[$form_state['values']['type']]['action_type'] = ActionsHelper::filterForRules($form_state['values']['node_expire_type_cfg_action_type']);
variable_set('node_expire_ntypes', $ntypes);
ModuleUtils::doVariablesCleanup();
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
FormHookHelper:: |
public static | function | Implements hook_form_alter(). | |
FormHookHelper:: |
public static | function | Implements hook_form_alter(). |