Created
December 18, 2017 20:04
-
-
Save opengeek/321df54f236af4dd8fc126c257e7cdfc to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$tstart = microtime(true); | |
set_time_limit(0); | |
require 'config.core.php'; | |
require MODX_CORE_PATH . 'model/modx/modx.class.php'; | |
$modx = modX::getInstance(); | |
$modx->initialize('mgr'); | |
$modx->setLogLevel(modX::LOG_LEVEL_INFO); | |
$modx->setLogTarget('ECHO'); | |
$resourceGroupName = "Default"; | |
$modx->log(modX::LOG_LEVEL_INFO, "Adding all resources to resource group {$resourceGroupName}"); | |
try { | |
$iterator = $modx->getIterator('modResource'); | |
foreach ($iterator as $resource) { | |
if (!$resource->isMember($resourceGroupName)) { | |
$resource->joinGroup($resourceGroupName); | |
} | |
} | |
} catch (Exception $e) { | |
$tend = microtime(true); | |
$totalTime= sprintf("%2.4f seconds", ($tend - $tstart)); | |
$modx->log(modX::LOG_LEVEL_ERROR, "Failed adding resources to resource group {$resourceGroupName} in {$totalTime}: {$e->getMessage()}"); | |
} | |
$tend = microtime(true); | |
$totalTime= sprintf("%2.4f seconds", ($tend - $tstart)); | |
$modx->log(modX::LOG_LEVEL_INFO, "Added all resources to resource group {$resourceGroupName} in {$totalTime}"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment