public function actionMigrate($old, $replace)
    {
        $block = Block::find()->where(['like', 'class', $old])->one();
        
        if (!$block) {
            return $this->outputError("Unable to find a block for '{$old}'");
        }
        
        $this->outputInfo("Found block '{$block->class}' with ID {$block->id} used {$block->usageCount} times.");
        
        // check if existing block have the new replace name
        
        $replaceBlock = Block::find()->where(['like', 'class', $replace])->one();
        
        if ($replaceBlock && $this->confirm("Do you want to replace {$block->class} (used {$block->usageCount}x) with {$replaceBlock->class} (used {$replaceBlock->usageCount}x)?")) {
            $block->updateAttributes(['class' => $replaceBlock->class]);
            
            if (empty($replaceBlock->usageCount)) {
                $replaceBlock->delete();
                
                return $this->outputSuccess("The block as been migrated, the block used for the replacement has been delete has there was no content.");
            } else {
                $replaceBlock->updateAttributes(['class' => $block->class]);
                
                return $this->outputSuccess("The block has been migrated and the block class names has swaped as the replacement block had content.");
            }
        }
        
        return $this->outputError("Abort by user.");
    }
public function actionMigrate($old, $replace)
    {
        $block = Block::find()->where(['like', 'class', $old])->one();
        
        if (!$block) {
            return $this->outputError("Unable to find a block for '{$old}'");
        }
        
        $this->outputInfo("Found block '{$block->class}' with ID {$block->id} used {$block->usageCount} times.");
        
        // check if existing block have the new replace name
        
        $replaceBlock = Block::find()->where(['like', 'class', $replace])->one();
        
        if ($replaceBlock && $this->confirm("Do you want to replace {$block->class} (used {$block->usageCount}x) with {$replaceBlock->class} (used {$replaceBlock->usageCount}x)?")) {
            $block->updateAttributes(['class' => $replaceBlock->class]);
            
            if (empty($replaceBlock->usageCount)) {
                $replaceBlock->delete();
                
                return $this->outputSuccess("The block as been migrated, the block used for the replacement has been delete has there was no content.");
            } else {
                $replaceBlock->updateAttributes(['class' => $block->class]);
                
                return $this->outputSuccess("The block has been migrated and the block class names has swaped as the replacement block had content.");
            }
        }
        
        return $this->outputError("Abort by user.");
    }
public function actionMigrate ( $ old , $ replace ) { $ block = Block :: find ( ) -> where ( [ 'like' , 'class' , $ old ] ) -> one ( ) ; if ( ! $ block ) { return $ this -> outputError ( "Unable to find a block for '{$old}'" ) ; } $ this -> outputInfo ( "Found block '{$block->class}' with ID {$block->id} used {$block->usageCount} times." ) ; // check if existing block have the new replace name $ replaceBlock = Block :: find ( ) -> where ( [ 'like' , 'class' , $ replace ] ) -> one ( ) ; if ( $ replaceBlock && $ this -> confirm ( "Do you want to replace {$block->class} (used {$block->usageCount}x) with {$replaceBlock->class} (used {$replaceBlock->usageCount}x)?" ) ) { $ block -> updateAttributes ( [ 'class' => $ replaceBlock -> class ] ) ; if ( empty ( $ replaceBlock -> usageCount ) ) { $ replaceBlock -> delete ( ) ; return $ this -> outputSuccess ( "The block as been migrated, the block used for the replacement has been delete has there was no content." ) ; } else { $ replaceBlock -> updateAttributes ( [ 'class' => $ block -> class ] ) ; return $ this -> outputSuccess ( "The block has been migrated and the block class names has swaped as the replacement block had content." ) ; } } return $ this -> outputError ( "Abort by user." ) ; }
Search for a given block and replace the class by replace argument.

This is commonly used when a block does not exists anymore and you want to provide
another block for the none existing one.

The most common case is to search ($old) for a class which has been used in the content but does not exist anymore,
therfore you can replace it with a new ($replace) block which has not been used in the content. This will change the
class identifier from the old block with the new (replace) ones. If the replace block has not been used, he will be deleted.

Searching for the blocks could look like this:

```sh
./luya cms/block/migrate OldBlockWhichDoesNotExists TheNewBlockWhichShouldReplaceTheOld
```

Example for using different namespaces but the same block name:

```sh
./luya cms/block/migrate \\blocks\\MyBlock \\newblocks\\MyBlock
```

Example usage when working with absolute class names.

```sh
./luya cms/block/migrate app\\blocks\\OldBlockName app\\blocks\\NewBlockName
```

As the search for the old block is done by a like statements this would work as well:

```sh
./luya cms/block/migrate OldBlockName app\\blocks\\NewBlockName
```

@param string $old
@param string $replace
@since 1.0.4
Search for a given block and replace the class by replace argument .