/**
  * Executes commit action on content and its draft.
  *
  * @param  AbstractClassContent $content
  * @param  Revision             $draft
  *
  * @return ClassContentManager
  */
 private function executeCommit(AbstractClassContent $content, Revision $draft)
 {
     $content->setDraft(null);
     if ($content instanceof ContentSet) {
         $content->clear();
         while ($subcontent = $draft->next()) {
             if ($subcontent instanceof AbstractClassContent) {
                 $subcontent = $this->entityManager->getRepository(ClassUtils::getRealClass($subcontent))->load($subcontent);
                 if (null !== $subcontent) {
                     $content->push($subcontent);
                 }
             }
         }
     } else {
         foreach ($draft->getData() as $key => $values) {
             $values = is_array($values) ? $values : [$values];
             foreach ($values as &$subcontent) {
                 if ($subcontent instanceof AbstractClassContent) {
                     $subcontent = $this->entityManager->getRepository(ClassUtils::getRealClass($subcontent))->load($subcontent);
                 }
             }
             unset($subcontent);
             if (in_array('Element\\Keyword', $content->getAccept()[$key])) {
                 $this->entityManager->getRepository('BackBee\\ClassContent\\Element\\Keyword')->cleanKeywordLinks($content, $values);
             }
             $content->{$key} = $values;
         }
     }
     $draft->commit();
     $content->setLabel($draft->getLabel());
     foreach ($draft->getAllParams() as $key => $params) {
         $content->setParam($key, $params['value']);
     }
     $content->setRevision($draft->getRevision())->setState(AbstractClassContent::STATE_NORMAL)->addRevision($draft);
     return $this;
 }