protected function doPersistResource(ResourceInterface $resource, $autoCommit, $type)
    {
        $object = $resource->getRealData();
        $this->validateUndeleteResource($resource, $type);
        $this->validateResource($resource, $type);
        $successStatus = $this->getSuccessStatus($type, $object);
        $hasFlushError = false;

        if ($resource->isValid()) {
            try {
                $this->om->persist($object);
                $hasFlushError = $this->doAutoCommitFlushTransaction($resource, $autoCommit);
            } catch (\Exception $e) {
                $hasFlushError = DomainUtil::injectErrorMessage($this->translator, $resource, $e, $this->debug);
            }
        }

        return [$successStatus, $hasFlushError];
    }