commands/XmlSoccerController.php
public function actionShowLeagues()
    {
        $leagues = call_user_func([$this->leagueClass, 'find']);
        /* @var $leagues \yii\db\ActiveQuery */

        if (!$leagues->count('id')) {
            $this->stdout("No leagues found. Import by ");
            $this->stdout("{$this->id}/import-leagues", Console::BOLD);
            $this->stdout("\n");
            return ExitCode::OK;
        }

        $first = $leagues->one();
        $headers = [];
        $rows = [];
        $attributes = [];

        foreach ($first->toArray() as $attribute => $value) {
            $attributes[] = $attribute;
            $headers[] = $first->generateAttributeLabel($attribute);
        }
        foreach ($leagues->all() as $league) {
            $rows[] = array_values($league->toArray($attributes));
        }

        echo Table::widget([
            'headers' => $headers,
            'rows' => $rows
        ]);

        return ExitCode::OK;
    }
public function actionShowLeagues()
    {
        $leagues = call_user_func([$this->leagueClass, 'find']);
        /* @var $leagues \yii\db\ActiveQuery */

        if (!$leagues->count('id')) {
            $this->stdout("No leagues found. Import by ");
            $this->stdout("{$this->id}/import-leagues", Console::BOLD);
            $this->stdout("\n");
            return ExitCode::OK;
        }

        $first = $leagues->one();
        $headers = [];
        $rows = [];
        $attributes = [];

        foreach ($first->toArray() as $attribute => $value) {
            $attributes[] = $attribute;
            $headers[] = $first->generateAttributeLabel($attribute);
        }
        foreach ($leagues->all() as $league) {
            $rows[] = array_values($league->toArray($attributes));
        }

        echo Table::widget([
            'headers' => $headers,
            'rows' => $rows
        ]);

        return ExitCode::OK;
    }
public function actionShowLeagues ( ) { $ leagues = call_user_func ( [ $ this -> leagueClass , 'find' ] ) ; /* @var $leagues \yii\db\ActiveQuery */ if ( ! $ leagues -> count ( 'id' ) ) { $ this -> stdout ( "No leagues found. Import by " ) ; $ this -> stdout ( "{$this->id}/import-leagues" , Console :: BOLD ) ; $ this -> stdout ( "\n" ) ; return ExitCode :: OK ; } $ first = $ leagues -> one ( ) ; $ headers = [ ] ; $ rows = [ ] ; $ attributes = [ ] ; foreach ( $ first -> toArray ( ) as $ attribute => $ value ) { $ attributes [ ] = $ attribute ; $ headers [ ] = $ first -> generateAttributeLabel ( $ attribute ) ; } foreach ( $ leagues -> all ( ) as $ league ) { $ rows [ ] = array_values ( $ league -> toArray ( $ attributes ) ) ; } echo Table :: widget ( [ 'headers' => $ headers , 'rows' => $ rows ] ) ; return ExitCode :: OK ; }
Show all leagues

@return integer Exit code
@throws \Exception
Show all leagues