Example #1
1
 /**
  * @param  ArrayHash $values
  * @param  Entities\UserEntity $user
  * @param  Entities\WikiEntity $wiki
  * @param  Entities\WikiDraftEntity $e
  * @throws PossibleUniqueKeyDuplicationException
  * @return Entities\WikiEntity
  */
 public function create(ArrayHash $values, Entities\UserEntity $user, Entities\WikiEntity $wiki, Entities\WikiDraftEntity $e)
 {
     $e->setValues($values);
     $e->text = $this->htmlPurifier->purify($values->text);
     $e->wiki = $wiki;
     $e->user = $user;
     $e->createdAt = new DateTime();
     $this->persistAndFlush($this->em, $e);
     return $e;
 }
Example #2
0
 public function update(ArrayHash $values, Entities\TagEntity $tag, Entities\UserEntity $user, Entities\ArticleEntity $e)
 {
     if ($e->tag->id !== $tag->id) {
         $this->menuCache->deleteSection(MenuCache::SECTION_ARTICLES);
     }
     $e->setValues($values);
     if ($e->tag->id !== $tag->id && $this->getByTagAndName($tag, $values->name)) {
         throw new PossibleUniqueKeyDuplicationException($this->translator->translate('locale.duplicity.article_tag_and_name'));
     }
     $e->slug = $e->slug ?: Slugger::slugify($e->name);
     if ($e->tag->id !== $tag->id && $this->getByTagAndSlug($tag, $e->slug)) {
         throw new PossibleUniqueKeyDuplicationException($this->translator->translate('locale.duplicity.article_tag_and_slug'));
     }
     $e->text = $this->htmlPurifier->purify($values->text);
     $e->tag = $tag;
     $e->user = $user;
     $this->persistAndFlush($this->em, $e);
     return $e;
 }
Example #3
0
 /**
  * @param  Entities\WikiEntity      $e
  * @param  Entities\WikiDraftEntity $draft
  * @return Entities\WikiEntity
  */
 public function updateWithDraft(Entities\WikiEntity $e, Entities\WikiDraftEntity $draft)
 {
     $e->perex = $draft->perex;
     $e->text = $this->htmlPurifier->purify($draft->text);
     $e->lastUpdatedBy = $draft->user;
     $e->updatedAt = $draft->createdAt;
     foreach (array_reverse($e->drafts->toArray()) as $d) {
         if ($draft->id < $d->id) {
             break;
         }
         if ($e->contributors->contains($d->user) === false) {
             $e->contributors->add($d->user);
         }
         $e->drafts->removeElement($d);
         $this->em->remove($d);
     }
     $this->persistAndFlush($this->em, $e);
     return $e;
 }
 /**
  * Filter
  *
  * @see Zend_Filter_Interface::filter
  * @param string $value
  * @return string
  */
 public function filter($value)
 {
     return $this->_purifier->purify($value);
 }