Created
September 1, 2025 12:57
-
-
Save wsydney76/bc59ea54117b74fe25d51644af1bef68 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 | |
namespace modules\temp\console\controllers; | |
use Craft; | |
use craft\console\Controller; | |
use craft\elements\Entry; | |
use yii\console\ExitCode; | |
/** | |
* Reorder Structure controller | |
*/ | |
class ReorderStructureController extends Controller | |
{ | |
public $defaultAction = 'index'; | |
/** | |
* temp/reorder-structure command | |
*/ | |
public function actionIndex(): int | |
{ | |
Craft::$app->db->backup(); | |
$entries = Entry::find() | |
->section('storageLocation') | |
->all(); | |
foreach ($entries as $entry) { | |
$this->stdout($entry->title. "\n"); | |
Craft::$app->getStructures()->prependToRoot($entry->structureId, $entry); | |
} | |
return ExitCode::OK; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment