public function actionCleanup()
    {
        $delete = [];
        $this->output("Blocks to delete:");
        foreach (Block::find()->all() as $block) {
            if (!$block->getFileExists()) {
                $this->outputInfo("{$block->class} (id: {$block->id}) used {$block->usageCount} times.");
                $delete[] = $block;
            }
        }
        
        if (!empty($delete) && $this->confirm('Are you sure to delete those blocks with its content? This can not be undone!')) {
            foreach ($delete as $deleteBlock) {
                if ($deleteBlock->delete()) {
                    $this->outputSuccess('Deleted ' . $deleteBlock->class);
                } else {
                    $this->outputError('Error while deleting ' . $deleteBlock->class);
                }
            }
            
            return $this->outputSuccess("Clean has been finished successful.");
        } elseif (empty($delete)) {
            return $this->outputSuccess("Nothing to cleanup.");
        }
        
        return $this->outputError("Abort by user.");
    }
public function actionCleanup()
    {
        $delete = [];
        $this->output("Blocks to delete:");
        foreach (Block::find()->all() as $block) {
            if (!$block->getFileExists()) {
                $this->outputInfo("{$block->class} (id: {$block->id}) used {$block->usageCount} times.");
                $delete[] = $block;
            }
        }
        
        if (!empty($delete) && $this->confirm('Are you sure to delete those blocks with its content? This can not be undone!')) {
            foreach ($delete as $deleteBlock) {
                if ($deleteBlock->delete()) {
                    $this->outputSuccess('Deleted ' . $deleteBlock->class);
                } else {
                    $this->outputError('Error while deleting ' . $deleteBlock->class);
                }
            }
            
            return $this->outputSuccess("Clean has been finished successful.");
        } elseif (empty($delete)) {
            return $this->outputSuccess("Nothing to cleanup.");
        }
        
        return $this->outputError("Abort by user.");
    }
public function actionCleanup ( ) { $ delete = [ ] ; $ this -> output ( "Blocks to delete:" ) ; foreach ( Block :: find ( ) -> all ( ) as $ block ) { if ( ! $ block -> getFileExists ( ) ) { $ this -> outputInfo ( "{$block->class} (id: {$block->id}) used {$block->usageCount} times." ) ; $ delete [ ] = $ block ; } } if ( ! empty ( $ delete ) && $ this -> confirm ( 'Are you sure to delete those blocks with its content? This can not be undone!' ) ) { foreach ( $ delete as $ deleteBlock ) { if ( $ deleteBlock -> delete ( ) ) { $ this -> outputSuccess ( 'Deleted ' . $ deleteBlock -> class ) ; } else { $ this -> outputError ( 'Error while deleting ' . $ deleteBlock -> class ) ; } } return $ this -> outputSuccess ( "Clean has been finished successful." ) ; } elseif ( empty ( $ delete ) ) { return $ this -> outputSuccess ( "Nothing to cleanup." ) ; } return $ this -> outputError ( "Abort by user." ) ; }
Search for blocks with none existing class files and remove them.

> Attention: Keep in the mind if the blocks do have been used in content, those data will be delete as well!

@since 1.0.4
Search for blocks with none existing class files and remove them .