* Batch API callbacks for the linkchecker module.
*/
+use \Drupal\node\Entity\Node;
+
/**
* Batch: Scan nodes for links.
*/
-function _linkchecker_batch_import_nodes($node_types = array()) {
+function _linkchecker_batch_import_nodes($node_types = []) {
// Get all active {node}.nid's.
- $result = db_query('SELECT n.nid FROM {node} n WHERE n.status = :status AND n.type IN (:types) ORDER BY n.nid', array(':status' => 1, ':types' => $node_types));
+ $result = db_query('SELECT n.nid FROM {node} n WHERE n.status = :status AND n.type IN (:types) ORDER BY n.nid', [':status' => 1, ':types' => $node_types]);
- $operations = array();
+ $operations = [];
foreach ($result as $row) {
- $operations[] = array('_linkchecker_batch_node_import_op', array($row->nid));
+ $operations[] = ['_linkchecker_batch_node_import_op', [$row->nid]];
}
- $batch = array(
+ $batch = [
'file' => drupal_get_path('module', 'linkchecker') . '/linkchecker.batch.inc',
'finished' => '_linkchecker_batch_node_import_finished',
'operations' => $operations,
'title' => t('Scanning for links'),
- );
+ ];
return $batch;
}
*/
function _linkchecker_batch_node_import_op($nid, &$context) {
// Load the node and scan for links.
- $node = node_load($nid, NULL, TRUE);
+ $node = Node::load($nid);
_linkchecker_add_node_links($node);
// Store results for post-processing in the finished callback.
$context['results'][] = $node->nid;
- $context['message'] = t('Content: @title', array('@title' => $node->title));
+ $context['message'] = t('Content: @title', ['@title' => $node->title]);
}
/**
* @param array $operations
* Array of functions called.
*/
-function _linkchecker_batch_node_import_finished($success, $results, $operations) {
+function _linkchecker_batch_node_import_finished($success, $results, array $operations) {
if ($success) {
- $message = format_plural(count($results), 'One node has been scanned.', '@count nodes have been scanned.');
+ $message = \Drupal::translation()->formatPlural(count($results), 'One node has been scanned.', '@count nodes have been scanned.');
}
else {
$message = t('Scanning for links in content has failed with an error.');
/**
* Batch: Scan comments for links.
*/
-function _linkchecker_batch_import_comments($node_types = array()) {
+function _linkchecker_batch_import_comments($node_types = []) {
// Get all active {comment}.cid's.
- $result = db_query('SELECT c.cid FROM {comment} c INNER JOIN {node} n ON c.nid = n.nid WHERE c.status = :cstatus AND n.status = :nstatus AND n.type IN (:types) ORDER BY c.cid', array(':cstatus' => COMMENT_PUBLISHED, ':nstatus' => 1, ':types' => $node_types));
+ $result = db_query('SELECT c.cid FROM {comment} c INNER JOIN {node} n ON c.nid = n.nid WHERE c.status = :cstatus AND n.status = :nstatus AND n.type IN (:types) ORDER BY c.cid', [':cstatus' => COMMENT_PUBLISHED, ':nstatus' => 1, ':types' => $node_types]);
- $operations = array();
+ $operations = [];
foreach ($result as $row) {
- $operations[] = array('_linkchecker_batch_comments_import_op', array($row->cid));
+ $operations[] = ['_linkchecker_batch_comments_import_op', [$row->cid]];
}
- $batch = array(
+ $batch = [
'file' => drupal_get_path('module', 'linkchecker') . '/linkchecker.batch.inc',
'finished' => '_linkchecker_batch_comments_import_finished',
'operations' => $operations,
'title' => t('Scanning for links'),
- );
+ ];
return $batch;
}
// Store results for post-processing in the finished callback.
$context['results'][] = $comment->cid;
- $context['message'] = t('Comment: @title', array('@title' => $comment->subject));
+ $context['message'] = t('Comment: @title', ['@title' => $comment->subject]);
}
/**
* @param array $operations
* Array of functions called.
*/
-function _linkchecker_batch_comments_import_finished($success, $results, $operations) {
+function _linkchecker_batch_comments_import_finished($success, $results, array $operations) {
if ($success) {
- $message = format_plural(count($results), 'One comment has been scanned.', '@count comments have been scanned.');
+ $message = \Drupal::translation()->formatPlural(count($results), 'One comment has been scanned.', '@count comments have been scanned.');
}
else {
$message = t('Scanning for links in comments have failed with an error.');
// Get all {block_custom}.bid's as block module suxxx and has no usable hooks.
$result = db_query('SELECT bid FROM {block_custom} ORDER BY bid');
- $operations = array();
+ $operations = [];
foreach ($result as $row) {
- $operations[] = array('_linkchecker_batch_import_block_custom_op', array($row->bid));
+ $operations[] = ['_linkchecker_batch_import_block_custom_op', [$row->bid]];
}
- $batch = array(
+ $batch = [
'file' => drupal_get_path('module', 'linkchecker') . '/linkchecker.batch.inc',
'finished' => '_linkchecker_batch_block_custom_import_finished',
'operations' => $operations,
'title' => t('Scanning for links'),
- );
+ ];
return $batch;
}
// Store some result for post-processing in the finished callback.
$context['results'][] = $block_custom->delta;
- $context['message'] = t('Block: @title', array('@title' => $block_custom->info));
+ $context['message'] = t('Block: @title', ['@title' => $block_custom->info]);
}
/**
* @param array $operations
* Array of functions called.
*/
-function _linkchecker_batch_block_custom_import_finished($success, $results, $operations) {
+function _linkchecker_batch_block_custom_import_finished($success, $results, array $operations) {
if ($success) {
- $message = format_plural(count($results), 'One block has been scanned.', '@count blocks have been scanned.');
+ $message = \Drupal::translation()->formatPlural(count($results), 'One block has been scanned.', '@count blocks have been scanned.');
}
else {
$message = t('Scanning for links in blocks have failed with an error.');
* The batch task definition.
*/
function _linkchecker_batch_import_single_node($nid, $missing_links_count) {
- $operations = array();
+ $operations = [];
for ($i = 0; $i <= $missing_links_count; $i = $i + LINKCHECKER_SCAN_MAX_LINKS_PER_RUN) {
- $operations[] = array('_linkchecker_batch_single_node_import_op', array($nid));
+ $operations[] = ['_linkchecker_batch_single_node_import_op', [$nid]];
}
- $batch = array(
+ $batch = [
'file' => drupal_get_path('module', 'linkchecker') . '/linkchecker.batch.inc',
'finished' => '_linkchecker_batch_single_node_import_finished',
'operations' => $operations,
'title' => t('Scanning for links'),
'progress_message' => t('Remaining @remaining of @total scans.'),
- );
+ ];
return $batch;
}
* @param array $context
* Batch context array.
*/
-function _linkchecker_batch_single_node_import_op($nid, &$context) {
+function _linkchecker_batch_single_node_import_op($nid, array &$context) {
// Load the node and scan for links.
$node = node_load($nid, NULL, TRUE);
_linkchecker_add_node_links($node, TRUE);
// Store results for post-processing in the finished callback.
$context['results'][] = $node->nid;
- $context['message'] = t('Content: @title', array('@title' => $node->title));
+ $context['message'] = t('Content: @title', ['@title' => $node->title]);
}
/**
* @param array $operations
* Array of functions called.
*/
-function _linkchecker_batch_single_node_import_finished($success, $results, $operations) {
+function _linkchecker_batch_single_node_import_finished($success, $results, array $operations) {
if ($success) {
- $message = format_plural(count($results), 'Node @nid has been re-scanned once to collect all links.', 'Node @nid has been re-scanned @count times to collect all links.', array('@nid' => $results[0]));
+ $message = \Drupal::translation()->formatPlural(count($results), 'Node @nid has been re-scanned once to collect all links.', 'Node @nid has been re-scanned @count times to collect all links.', ['@nid' => $results[0]]);
}
else {
- $message = t('Recurring scanning for links in node @nid has failed with an error.', array('@nid' => $results[0]));
+ $message = t('Recurring scanning for links in node @nid has failed with an error.', ['@nid' => $results[0]]);
}
drupal_set_message($message);
}
* The batch task definition.
*/
function _linkchecker_batch_import_single_comment($cid, $missing_links_count) {
- $operations = array();
+ $operations = [];
for ($i = 0; $i <= $missing_links_count; $i = $i + LINKCHECKER_SCAN_MAX_LINKS_PER_RUN) {
- $operations[] = array('_linkchecker_batch_single_comment_import_op', array($cid));
+ $operations[] = ['_linkchecker_batch_single_comment_import_op', [$cid]];
}
- $batch = array(
+ $batch = [
'file' => drupal_get_path('module', 'linkchecker') . '/linkchecker.batch.inc',
'finished' => '_linkchecker_batch_single_comment_import_finished',
'operations' => $operations,
'title' => t('Scanning for links'),
'progress_message' => t('Remaining @remaining of @total scans.'),
- );
+ ];
return $batch;
}
* @param array $context
* Batch context array.
*/
-function _linkchecker_batch_single_comment_import_op($cid, &$context) {
+function _linkchecker_batch_single_comment_import_op($cid, array &$context) {
$comment = comment_load($cid);
_linkchecker_add_comment_links($comment, TRUE);
// Store results for post-processing in the finished callback.
$context['results'][] = $comment->cid;
- $context['message'] = t('Comment: @title', array('@title' => $comment->subject));
+ $context['message'] = t('Comment: @title', ['@title' => $comment->subject]);
}
/**
* @param array $operations
* Array of functions called.
*/
-function _linkchecker_batch_single_comment_import_finished($success, $results, $operations) {
+function _linkchecker_batch_single_comment_import_finished($success, $results, array $operations) {
if ($success) {
- $message = format_plural(count($results), 'Comment @cid has been re-scanned once to collect all links.', 'Comment @cid has been re-scanned @count times to collect all links.', array('@cid' => $results[0]));
+ $message = \Drupal::translation()->formatPlural(count($results), 'Comment @cid has been re-scanned once to collect all links.', 'Comment @cid has been re-scanned @count times to collect all links.', ['@cid' => $results[0]]);
}
else {
- $message = t('Recurring scanning for links in comment @cid has failed with an error.', array('@cid' => $results[0]));
+ $message = t('Recurring scanning for links in comment @cid has failed with an error.', ['@cid' => $results[0]]);
}
drupal_set_message($message);
}
* The batch task definition.
*/
function _linkchecker_batch_import_single_block_custom($bid, $missing_links_count) {
- $operations = array();
+ $operations = [];
for ($i = 0; $i <= $missing_links_count; $i = $i + LINKCHECKER_SCAN_MAX_LINKS_PER_RUN) {
- $operations[] = array('_linkchecker_batch_single_block_custom_import_op', array($bid));
+ $operations[] = ['_linkchecker_batch_single_block_custom_import_op', [$bid]];
}
- $batch = array(
+ $batch = [
'file' => drupal_get_path('module', 'linkchecker') . '/linkchecker.batch.inc',
'finished' => '_linkchecker_batch_single_block_custom_import_finished',
'operations' => $operations,
'title' => t('Scanning for links'),
'progress_message' => t('Remaining @remaining of @total scans.'),
- );
+ ];
return $batch;
}
* @param array $context
* Batch context array.
*/
-function _linkchecker_batch_single_block_custom_import_op($bid, &$context) {
+function _linkchecker_batch_single_block_custom_import_op($bid, array &$context) {
// Load the custom block and scan for links.
$block_custom = linkchecker_block_custom_block_get($bid);
_linkchecker_add_block_custom_links($block_custom, $block_custom->delta, TRUE);
// Store some result for post-processing in the finished callback.
$context['results'][] = $block_custom->delta;
- $context['message'] = t('Block: @title', array('@title' => $block_custom->info));
+ $context['message'] = t('Block: @title', ['@title' => $block_custom->info]);
}
/**
* @param array $operations
* Array of functions called.
*/
-function _linkchecker_batch_single_block_custom_import_finished($success, $results, $operations) {
+function _linkchecker_batch_single_block_custom_import_finished($success, $results, array $operations) {
if ($success) {
- $message = format_plural(count($results), 'Block @bid has been re-scanned once to collect all links.', 'Block @bid has been re-scanned @count times to collect all links.', array('@bid' => $results[0]));
+ $message = \Drupal::translation()->formatPlural(count($results), 'Block @bid has been re-scanned once to collect all links.', 'Block @bid has been re-scanned @count times to collect all links.', ['@bid' => $results[0]]);
}
else {
- $message = t('Recurring scanning for links in block @bid has failed with an error.', array('@bid' => $results[0]));
+ $message = t('Recurring scanning for links in block @bid has failed with an error.', ['@bid' => $results[0]]);
}
drupal_set_message($message);
}