Utility.php in Helper 8
File
src/Utility.php
View source
<?php
namespace Drupal\helper;
class Utility {
public static function registerUniqueShutdownFunction(callable $callback = NULL) {
$args = func_get_args();
array_shift($args);
$existing_callbacks = drupal_register_shutdown_function();
foreach ($existing_callbacks as $existing_callback) {
if ($existing_callback['callback'] === $callback && $existing_callback['arguments'] === $args) {
return FALSE;
}
}
array_unshift($args, $callback);
call_user_func_array('drupal_register_shutdown_function', $args);
return TRUE;
}
public static function runBatch(array $batch) {
$existing_batch = batch_get();
$current_batch =& batch_get();
if ($existing_batch) {
$current_batch = NULL;
}
batch_set($batch);
$current_batch['progressive'] = FALSE;
batch_process();
if ($existing_batch) {
$current_batch = $existing_batch;
}
}
}
Classes
Name |
Description |
Utility |
Provides various utility helpers. |