node_expire.ntype.inc in Node expire 8
Same filename and directory in other branches
Node type integration.
File
node_expire.ntype.incView source
<?php
/**
* @file
* Node type integration.
*/
/**
* Implements hook_form_alter().
*/
function _node_expire_form_node_type_form_alter_validate(&$form, &$form_state) {
$node_expire =& $form_state['values']['node_expire'];
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_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 default value.'));
}
}
$node_expire_required =& $form_state['values']['node_expire_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().
*/
function _node_expire_form_node_type_form_alter_submit(&$form, &$form_state) {
// @FIXME
// Could not extract the default value because it is either indeterminate, or
// not scalar. You'll need to provide a default value in
// config/install/node_expire.settings.yml and config/schema/node_expire.schema.yml.
$ntypes = \Drupal::config('node_expire.settings')
->get('node_expire_ntypes');
$handle_content_expiry = \Drupal::config('node_expire.settings')
->get('node_expire_handle_content_expiry');
if ($handle_content_expiry != 0) {
$ntypes[$form_state['values']['type']]['enabled'] = $form_state['values']['node_expire_enabled'];
}
$ntypes[$form_state['values']['type']]['default'] = $form_state['values']['node_expire'];
$ntypes[$form_state['values']['type']]['max'] = $form_state['values']['node_expire_max'];
$ntypes[$form_state['values']['type']]['required'] = $form_state['values']['node_expire_required'];
\Drupal::config('node_expire.settings')
->set('node_expire_ntypes', $ntypes)
->save();
}
Functions
Name | Description |
---|---|
_node_expire_form_node_type_form_alter_submit | Implements hook_form_alter(). |
_node_expire_form_node_type_form_alter_validate | Implements hook_form_alter(). |