@CenterJoin

Парсер на Yii. Как оргю логику?

Мне нужно пасить XML но не знаю, что не так? Или что делать в модели?
Вот мой код(зашедший в ступор):
<?php

namespace app\controllers;

use application\models\Contract;

class ContractController extends \Controller
{
    public function actionMain()
    {
        $view = new Contract;
        $xml = simplexml_load_file('protected/data/list.xml');

        return $this->render('contr', [
            'contract' => ???
        ]);
    }
}


далее модель:
<?php

namespace application\models;

use yii\base\Model;

class Contract extends Model
{
    protected $id;
    protected $type;
    protected $contractType;
    protected $status;
    protected $contractID;
    protected $numberInternal;
    protected $numberPan;
    protected $currency;
    protected $openDate;
    protected $closeDate;
    protected $permission;

    /**
     * @return mixed
     */
    public function getId()
    {
        return $this->id;
    }

    /**
     * @return mixed
     */
    public function getType()
    {
        return $this->type;
    }

    /**
     * @return mixed
     */
    public function getContractType()
    {
        return $this->contractType;
    }

    /**
     * @return mixed
     */
    public function getStatus()
    {
        return $this->status;
    }

    /**
     * @return mixed
     */
    public function getContractID()
    {
        return $this->contractID;
    }

    /**
     * @return mixed
     */
    public function getNumberInternal()
    {
        return $this->numberInternal;
    }

    /**
     * @return mixed
     */
    public function getNumberPan()
    {
        return $this->numberPan;
    }

    /**
     * @return mixed
     */
    public function getCurrency()
    {
        return $this->currency;
    }

    /**
     * @return mixed
     */
    public function getOpenDate()
    {
        return $this->openDate;
    }

    /**
     * @return mixed
     */
    public function getCloseDate()
    {
        return $this->closeDate;
    }

    /**
     * @return mixed
     */
    public function getPermission()
    {
        return $this->permission;
    }
}

И вид:
<?php

    for ($i=0; $i < count($this->contract->contract); $i++)
    {
        echo $this->contract->contract[$i]->id;
        echo '<br>';
    }

?>
  • Вопрос задан
  • 73 просмотра
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы