protected function persistResource(ResourceEvent $event)
    {
        $resource = $event->getResource();

        // TODO Validation ?

        try {
            $this->manager->persist($resource);
            $this->manager->flush();
        } catch(DBALException $e) {
            if ($this->debug) {
                throw $e;
            }
            $event->addMessage(new ResourceMessage(
                'ekyna_admin.resource.message.persist.failure',
                ResourceMessage::TYPE_ERROR
            ));
            return $event;
        }

        return $event->addMessage(new ResourceMessage(
            'ekyna_admin.resource.message.persist.success',
            ResourceMessage::TYPE_SUCCESS
        ));
    }
protected function persistResource(ResourceEvent $event)
    {
        $resource = $event->getResource();

        // TODO Validation ?

        try {
            $this->manager->persist($resource);
            $this->manager->flush();
        } catch(DBALException $e) {
            if ($this->debug) {
                throw $e;
            }
            $event->addMessage(new ResourceMessage(
                'ekyna_admin.resource.message.persist.failure',
                ResourceMessage::TYPE_ERROR
            ));
            return $event;
        }

        return $event->addMessage(new ResourceMessage(
            'ekyna_admin.resource.message.persist.success',
            ResourceMessage::TYPE_SUCCESS
        ));
    }
protected function persistResource ( ResourceEvent $ event ) { $ resource = $ event -> getResource ( ) ; // TODO Validation ? try { $ this -> manager -> persist ( $ resource ) ; $ this -> manager -> flush ( ) ; } catch ( DBALException $ e ) { if ( $ this -> debug ) { throw $ e ; } $ event -> addMessage ( new ResourceMessage ( 'ekyna_admin.resource.message.persist.failure' , ResourceMessage :: TYPE_ERROR ) ) ; return $ event ; } return $ event -> addMessage ( new ResourceMessage ( 'ekyna_admin.resource.message.persist.success' , ResourceMessage :: TYPE_SUCCESS ) ) ; }
Persists a resource.

@param ResourceEvent $event
@return ResourceEvent
@throws DBALException
@throws \Exception
Persists a resource .