定义行为
@return array
13299
public function behaviors()
    {
        $behaviors = parent::behaviors();
        $behaviors['slug'] = [
            'class' => AttributeBehavior::className(),
            'attributes' => [
                ActiveRecord::EVENT_BEFORE_INSERT => ['slug']
            ],
            'value' => function ($event) {
                return Inflector::slug($event->sender->name,'');
            }
        ];
        $behaviors['letter'] = [
            'class' => AttributeBehavior::className(),
            'attributes' => [
                ActiveRecord::EVENT_BEFORE_INSERT => ['letter']
            ],
            'value' => function ($event) {
                return strtoupper(substr($event->sender->slug, 0, 1));
            }
        ];
        return $behaviors;
    }
971772
protected function execute()
    {
        $connection = $this->collection->getConnection();

        $rows = $connection->getCollectionData($this->collection->getName(), $this->criteria);

        $this->rows = array_slice($rows, $this->skip, $this->limit);

        foreach ((array) $this->sorts as $field => $flag) {
            usort($this->rows, function($a, $b) use ($field, $flag) {
                if (isset($a[$field])) {
                    $aValue = utf8_encode(filter_var((string) $a[$field], FILTER_SANITIZE_STRING));
                    $bValue = utf8_encode(filter_var((string) $b[$field], FILTER_SANITIZE_STRING));

                    return strcasecmp($aValue, $bValue) * (int) $flag;
                }
            });
        }
    }
586989
public function run()
    {
        if ($this->binding instanceof \Closure) {
            return call_user_func_array($this->binding, $this->parameters);
        }
        
        if (is_object($this->binding)) {
            return $this->binding;
        }
        
        if (is_string($this->binding)) {
            /*
             * @todo Implement this functionality
             */
            return null;
        }
        
        return $this->binding;
    }
344708
protected function getOneRow()
    {
        if (null === $this->cols) {
            $result = $this->statement->result_metadata();
            if (false === $result) return false;

            $this->cols = [];

            // set column name
            foreach ($result->fetch_fields() as $col) {
                $this->cols[] = $col->name;
            }

            // bind values
            $this->vals = array_fill(0, count($this->cols), null);

            $refs = [];
            foreach ($this->vals as $i => &$f) {
                $refs[$i] = &$f;
            }
            call_user_func_array([$this->statement, 'bind_result'], $refs);
        }

        if ($this->statement->fetch()) {
            $row = [];
            foreach($this->cols as $i => $col) {
                $row[$col] = $this->vals[$i];
            }
            return $row;
        }

        return false;
    }
865311
public function run()
    {
        $tag = ArrayHelper::remove($options, 'tag', 'ul');
        return Html::tag($tag, $this->top . $this->renderItems($this->items), $this->options);
    }
455191
public function select(): array
    {
        //生成请求游标
        $cursor = call_user_func_array([
            $this->collection,
            'find'
        ], func_get_args());

        //逐条取出结果,构造数组
        $result = [];
        while ($cursor->hasNext()) {
            $result[] = $cursor->getNext();
        }

        return $result;
    }
1303397
public function execute()
    {
        $result = [];
        foreach ($this->queryString() as $query) {
            $stmt = $this->connection->prepare($query);
            $stmt->execute();

            $result[] = $query;
        }

        $this->reset();

        return $result;
    }
195618
public function run()
	{
		if( isset( $this->config['task_list'] ) && !empty( $this->config['task_list'] ) ){
			$task_list            = $this->config['task_list'];
			$cronLastExecTimeList = [];
			// 定时执行
			ServerManager::getInstance()->getServer()->tick( $this->config['loop_time'] * 1000, function() use ( &$task_list, &$cronLastExecTimeList ){
				// 分别执行
				foreach( $task_list as $name => $option ){
					try{
						// 是到期需执行 当前时间 > 最后一次时间 + 间隔时间
						$last_time     = isset( $cronLastExecTimeList[$name] ) ? $cronLastExecTimeList[$name] : 0;
						$current_time  = time();
						$interval_time = ceil( $option['interval_time'] );

						if( $current_time > ($last_time + $interval_time) ){
							// 设置最后一次执行时间 不可等任务执行完毕后再设置时间，因为会阻塞导致每秒进行一次
							$cronLastExecTimeList[$name] = $current_time;
							// 检测是否可执行
							if( \ezswoole\Cron::checkTask( $name, $option ) === true ){
								\EasySwoole\Core\Swoole\Task\TaskManager::async( function() use ( $name, $option ){
									\ezswoole\Cron::exec( $name, $option );
									return true;
								} );
							} else{
								// 删除该任务
								unset( $task_list[$name] );
							}
						}
					} catch( \Exception $e ){
						\EasySwoole\EasySwoole\Logger::getInstance()->log($e->getTraceAsString(),'error');
					}
				}
			} );
		}
		return true;
	}
1007018
protected function doRun()
    {
        $result = 0;
        $args = func_get_args();
        $host = $this->session->getHost();

        if (count($args) === 3) {
            list($method, $params, $retval) = $args;

            // Strip namespace 
            $method = trim(str_replace(__NAMESPACE__, '', $method),'\\');
            $command = $method.' => ['.implode(' , ', $params).']';
            $this->printOut('<comment>' . $host . '</comment> < <info>' . $command.'</info>');

            // Initial result evaluation
            $result = $retval;
            $halt = $result == false;

            // Prints process information
            // @codeCoverageIgnoreStart
            if ($halt) {
                $this->printOut('<error>Aborted</error>');
            } else {
                if (is_string($retval) || is_array($retval)) {

                    if(is_array($retval)) {
                        foreach ($retval as $key => $val) {
                            if ( ! is_numeric($key)) $resultDioArray[] = $key.':'.$val;
                        }
                    } else {
                        $resultDioArray = array_filter(explode("\n", $retval));
                    }


                    foreach ($resultDioArray as $i => $resultDioLine) {
                        $this->printOut((($i === 0) ? '<comment>'.$host.'</comment>' : str_pad(' ', strlen($host))).' > <info>'.$resultDioLine.'</info>');
                    }
                } else {
                    $this->printOut('<comment>'.$host.'</comment> > <info>[OK]</info>');
                }
            }
            // @codeCoverageIgnoreEnd
        }

        return $result;
    }
673124
public function run()
    {
        // 初始化
        reset($this->queue);
        for ($i = 0; $i < $this->max; $i++) {
            if ($this->makeTask() == -1) {
                break;
            }
        }
        // 处理任务队列
        reset($this->tasks);
        while (count($this->tasks) > 0) {
            $task = current($this->tasks);
            $this->processTask($task);
            if ($task['status'] == -1 || $task['status'] == 2) {
                if ($this->saveSuccess) {
                    $this->success[] = $task;
                }
                unset($this->tasks[key($this->tasks)]);
                $this->makeTask();
            } else {
                $this->tasks[key($this->tasks)] = $task;
            }
            if (!next($this->tasks)) {
                reset($this->tasks);
            }
        }
        return $this->getSuccessInfo();
    }
323087
protected function runSelect()
    {
        if ($this->lock) {
            $this->connection->beginTransaction();
            $result = $this->connection->select($this->toSql(), $this->getBindings(), ! $this->useWritePdo);
            $this->connection->commit();

            return $result;
        }

        return $this->connection->select($this->toSql(), $this->getBindings(), ! $this->useWritePdo);
    }
453712
public function run()
    {
        if (yii::$app->getRequest()->getIsPost()) {//只允许post删除
            $id = yii::$app->getRequest()->get($this->paramSign, null);
            $param = yii::$app->getRequest()->post($this->paramSign, null);
            if($param !== null){
                $id = $param;
            }

            if( yii::$app->getRequest()->getIsAjax() ){
                yii::$app->getResponse()->format = $this->ajaxResponseFormat;
            }
            if (! $id) {
                throw new BadRequestHttpException(yii::t('app', "Id doesn't exit"));
            }
            if(is_array($id)){
                $ids = $id;
            }else{
                $ids = explode(',', $id);
            }

            $errorIds = [];
            /* @var $model yii\db\ActiveRecord */
            $model = null;
            foreach ($ids as $one) {
                $model = call_user_func([$this->modelClass, 'findOne'], $one);
                if ($model) {
                    $model->setScenario($this->scenario);
                    if (! $result = $model->delete()) {
                        $errorIds[] = $one;
                    }
                }
            }
            if (count($errorIds) == 0) {
                if( !yii::$app->getRequest()->getIsAjax() ) return $this->controller->redirect(yii::$app->getRequest()->headers['referer']);
                return ['status'=>true,'msg'=>yii::t('app','Success')];
            } else {
                $errors = $model->getErrors();
                $err = '';
                foreach ($errors as $v) {
                    $err .= $v[0];
                }
                if ($err != '') {
                    $err = '.' . $err;
                }
                throw new UnprocessableEntityHttpException('id ' . implode(',', $errorIds) . $err);
            }
        } else {
            throw new MethodNotAllowedHttpException(yii::t('app', "Delete must be POST http method"));
        }
    }
753955
public function exec()
    {
        return $this->db->fetchAffected(
            $this->query->__toString(),
            $this->query->getBindValues()
        );
    }
826775
public function run()
    {
        DB::table('ctrystore_administrative_areas')->delete();

        $today = date('Y-m-d H:i:s');
        $data = [
            ['name' => 'Tarapacá', 'code' => 'TA', 'tag' => 'I'],
            ['name' => 'Antofagasta', 'code' => 'AN', 'tag' => 'II'],
            ['name' => 'Atacama', 'code' => 'AT', 'tag' => 'III'],
            ['name' => 'Coquimbo', 'code' => 'CO', 'tag' => 'IV'],
            ['name' => 'Valparaíso', 'code' => 'VS', 'tag' => 'V'],
            [
                'name' => "Libertador Gral. Bernardo O'higgins",
                'code' => 'LI',
                'tag' => 'VI'
            ],
            ['name' => 'Maule', 'code' => 'ML', 'tag' => 'VII'],
            ['name' => 'BioBio', 'code' => 'BI', 'tag' => 'VIII'],
            ['name' => 'Araucania', 'code' => 'AR', 'tag' => 'IX'],
            ['name' => 'Los Lagos', 'code' => 'LL', 'tag' => 'X'],
            [
                'name' => 'Aysén del Gral. Carlos Ibáñez del Campo',
                'code' => 'AI',
                'tag' => 'XI'
            ],
            ['name' => 'Magallanes', 'code' => 'MA', 'tag' => 'XII'],
            ['name' => 'Metropolitana', 'code' => 'RM', 'tag' => 'XIII'],
            ['name' => 'Los Ríos', 'code' => 'LR', 'tag' => 'XIV'],
            ['name' => 'Arica y Parinacota', 'code' => 'AP', 'tag' => 'XV'],
            ['name' => 'Ñuble', 'code' => '', 'tag' => 'XVI']
        ];

        foreach ($data as $i => $ad) {
            DB::table('ctrystore_administrative_areas')->insert([
                'id' => $i + 1,
                'country_id' => 152,
                'name' => $ad['name'],
                'code' => $ad['code'],
                'tag' => $ad['tag'],
                'admin_division_id' => 1,
                'created_at' => $today,
                'updated_at' => $today,
            ]);
        }
    }
173020
public function run()
    {
        $tag = ArrayHelper::remove($this->containerOptions, 'tag', 'div');
        $html[] = Html::beginTag($tag, $this->containerOptions);
        if ($this->renderHiddenInput) {
            $html[] = $this->renderHiddenInput();
        }

        $html[] = Html::beginTag('div', ['class' => 'chips']);

        $html[] = Html::endTag('div');
        $html[] = Html::endTag($tag);
        return implode("\n", $html);
    }
123245
public function run()
    {
        if (! $this->runPreSearch()) {
            return $this->value;
        }

        $decoded = json_decode($this->value, 1);
        $result  = (json_last_error() == JSON_ERROR_NONE) && is_array($decoded);
        if ($result) {
            /* decoded is array */
            if (is_array($decoded)) {
                $arrayValue = '';
                array_walk_recursive($decoded, function ($value, $key) use (&$arrayValue) {
                    $arrayValue .= $key.' '.$value;
                });
                $this->value = $arrayValue;
            }
        }

        return $this->value;
    }
803819
public function run()
    {
        $route = $this->getRoute();
        $method = $this->getActionMethod(isset($route->action) ? $route->action : 'default');

        if (!method_exists($this, $method)) {
            return $this->notFound();
        }

        $this->before();
        
        if (!$this->isCancelled()) {
            $args = isset($route->args) ? $route->args
                : $this->getFunctionArgs($route, new \ReflectionMethod($this, $method)); 

            call_user_func_array([$this, $method], $args);
        }
        
        $this->after();
    }