<?php
/**
 * @link https://www.yiiframework.com/
 * @copyright Copyright (c) 2008 Yii Software LLC
 * @license https://www.yiiframework.com/license/
 */

namespace app\commands;

use app\common\CommonHelper;
use app\common\CurlApp;
use app\common\MobileHelper;
use app\models\Brand;
use app\models\BrandRunway;
use app\models\BrandSource;
use app\models\Clue;
use app\models\jobs\RunwayJob;
use app\models\logics\commands\SpiderVogue;
use app\models\Oauth;
use app\models\OauthAccount;
use app\models\OauthAccountLocal;
use app\models\User;
use GuzzleHttp\Client;
use GuzzleHttp\Psr7\Request;
use yii\console\Controller;
use yii\console\ExitCode;
use GuzzleHttp\Exception\RequestException;
use yii\helpers\ArrayHelper;


/**
 * This command echoes the first argument that you have entered.
 *
 * This command is provided as an example for you to learn how to create console commands.
 *
 * @author Qiang Xue <qiang.xue@gmail.com>
 * @since 2.0
 */
class SpiderController extends Controller
{


    public function __construct($id, $module, $config = [])
    {
        ini_set('pcre.backtrack_limit', '-1');
        parent::__construct($id, $module, $config);
    }


    public function actionVogue()
    {
        $model = new SpiderVogue();
        $model->start();
    }

    public function actionRunway()
    {

        foreach (BrandSource::find()->where(['is_deleted' => 0])->each() as $index => $item) {
            if ($index == 1) {
                \Yii::$app->queue->push(new RunwayJob([
                    'source' => $item,
                ]));die;
            }
        }
    }

}
