S
S
Steve2020-12-14 18:17:53
Yii
Steve, 2020-12-14 18:17:53

Parser in Yii. How to orgy logic?

I need to pasture XML but don't know what's wrong? Or what to do in the model?
Here is my code (in a stupor):

<?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' => ???
        ]);
    }
}


further model:
<?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;
    }
}

And view:
<?php

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

?>

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question