49 lines
		
	
	
		
			964 B
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			49 lines
		
	
	
		
			964 B
		
	
	
	
		
			PHP
		
	
	
	
	
	
<?php
 | 
						||
 | 
						||
/**
 | 
						||
 * @link https://www.kuvalda.ru/
 | 
						||
 * @copyright
 | 
						||
 * @license
 | 
						||
 */
 | 
						||
 | 
						||
namespace dominion\file\console;
 | 
						||
 | 
						||
use Yii;
 | 
						||
use yii\console\Controller;
 | 
						||
use yii\console\ExitCode;
 | 
						||
use dominion\file\File;
 | 
						||
 | 
						||
/**
 | 
						||
 * залить файлы с диска на s3
 | 
						||
 *
 | 
						||
 * @author Rybkin Sasha <ribkin@dominion.ru>
 | 
						||
 * @since 0.1
 | 
						||
 */
 | 
						||
class MoveController extends Controller
 | 
						||
{
 | 
						||
 | 
						||
    /**
 | 
						||
     * переносим данные с диска в s3
 | 
						||
     * @return int Exit code
 | 
						||
     */
 | 
						||
    public function actionIndex()
 | 
						||
    {
 | 
						||
        $flag = true;
 | 
						||
        $limit = 100;
 | 
						||
        $offset = 0;
 | 
						||
        while ($flag)
 | 
						||
        {
 | 
						||
            $models = File::find()->limit($limit)->offset($offset)->all();
 | 
						||
            foreach ($models as $model)
 | 
						||
            {
 | 
						||
                $model->moveToS3(false);
 | 
						||
            }
 | 
						||
            $flag = count($models) == $limit;
 | 
						||
            $offset += $limit;
 | 
						||
            echo "перенесено: {$offset} \n";
 | 
						||
        }
 | 
						||
        return ExitCode::OK;
 | 
						||
    }
 | 
						||
 | 
						||
}
 |