src/UthandoCommon/Service/AbstractMapperService.php
public function add(array $post, Form $form = null)
    {
        $model  = $this->getModel();
        $form   = ($form instanceof Form) ?
            $form->setData($post) :
            $this->prepareForm($model, $post, true, true);
        $argv   = compact('post', 'form');
        $argv   = $this->prepareEventArguments($argv);

        $this->getEventManager()->trigger(self::EVENT_PRE_ADD, $this, $argv);

        if (!$form->isValid()) {
            return $form;
        }

        $saved  = $this->save($form->getData());
        $argv   = compact('post', 'form', 'saved');
        $argv   = $this->prepareEventArguments($argv);

        $this->getEventManager()->trigger(self::EVENT_POST_ADD, $this, $argv);

        return $saved;
    }
public function add(array $post, Form $form = null)
    {
        $model  = $this->getModel();
        $form   = ($form instanceof Form) ?
            $form->setData($post) :
            $this->prepareForm($model, $post, true, true);
        $argv   = compact('post', 'form');
        $argv   = $this->prepareEventArguments($argv);

        $this->getEventManager()->trigger(self::EVENT_PRE_ADD, $this, $argv);

        if (!$form->isValid()) {
            return $form;
        }

        $saved  = $this->save($form->getData());
        $argv   = compact('post', 'form', 'saved');
        $argv   = $this->prepareEventArguments($argv);

        $this->getEventManager()->trigger(self::EVENT_POST_ADD, $this, $argv);

        return $saved;
    }
public function add ( array $ post , Form $ form = null ) { $ model = $ this -> getModel ( ) ; $ form = ( $ form instanceof Form ) ? $ form -> setData ( $ post ) : $ this -> prepareForm ( $ model , $ post , true , true ) ; $ argv = compact ( 'post' , 'form' ) ; $ argv = $ this -> prepareEventArguments ( $ argv ) ; $ this -> getEventManager ( ) -> trigger ( self :: EVENT_PRE_ADD , $ this , $ argv ) ; if ( ! $ form -> isValid ( ) ) { return $ form ; } $ saved = $ this -> save ( $ form -> getData ( ) ) ; $ argv = compact ( 'post' , 'form' , 'saved' ) ; $ argv = $ this -> prepareEventArguments ( $ argv ) ; $ this -> getEventManager ( ) -> trigger ( self :: EVENT_POST_ADD , $ this , $ argv ) ; return $ saved ; }
prepare and return form

@param array $post
@param Form $form
@return int|Form
@throws ServiceException
prepare and return form