public function postAction()
    {
        $data = json_decode($this->getRequest()->getRawBody());
        if (!is_array($data)) $data = array($data);

        $ret = array();
        foreach ($data as $d) {
            $row = $this->_model->createRow();
            if (isset($d->id) && $d->id) {
                $row->id = $d->id;
            }

            $this->_validateInsert((array)$d);
            $this->_validateSave((array)$d);
            $this->_fillRowInsert($row, $d);
            $this->_beforeInsert($row);
            $this->_beforeSave($row);
            $row->save();
            $this->_afterSave($row, $d);
            $this->_afterInsert($row, $d);

            $ret[] = $this->_loadDataFromRow($row);
        }
        if (count($ret) == 1) $ret = reset($ret);

        $this->view->data = $ret;
    }
public function postAction()
    {
        $data = json_decode($this->getRequest()->getRawBody());
        if (!is_array($data)) $data = array($data);

        $ret = array();
        foreach ($data as $d) {
            $row = $this->_model->createRow();
            if (isset($d->id) && $d->id) {
                $row->id = $d->id;
            }

            $this->_validateInsert((array)$d);
            $this->_validateSave((array)$d);
            $this->_fillRowInsert($row, $d);
            $this->_beforeInsert($row);
            $this->_beforeSave($row);
            $row->save();
            $this->_afterSave($row, $d);
            $this->_afterInsert($row, $d);

            $ret[] = $this->_loadDataFromRow($row);
        }
        if (count($ret) == 1) $ret = reset($ret);

        $this->view->data = $ret;
    }
public function postAction ( ) { $ data = json_decode ( $ this -> getRequest ( ) -> getRawBody ( ) ) ; if ( ! is_array ( $ data ) ) $ data = array ( $ data ) ; $ ret = array ( ) ; foreach ( $ data as $ d ) { $ row = $ this -> _model -> createRow ( ) ; if ( isset ( $ d -> id ) && $ d -> id ) { $ row -> id = $ d -> id ; } $ this -> _validateInsert ( ( array ) $ d ) ; $ this -> _validateSave ( ( array ) $ d ) ; $ this -> _fillRowInsert ( $ row , $ d ) ; $ this -> _beforeInsert ( $ row ) ; $ this -> _beforeSave ( $ row ) ; $ row -> save ( ) ; $ this -> _afterSave ( $ row , $ d ) ; $ this -> _afterInsert ( $ row , $ d ) ; $ ret [ ] = $ this -> _loadDataFromRow ( $ row ) ; } if ( count ( $ ret ) == 1 ) $ ret = reset ( $ ret ) ; $ this -> view -> data = $ ret ; }
Handle POST requests to create a new resource item
Handle POST requests to create a new resource item