Exemplo n.º 1
0
 /**
  * Finds last writing lock
  *
  * @param ArticleInterface $article
  * @return mixed
  */
 private function findWritingLockMeta(ArticleInterface $article)
 {
     $metaLock = null;
     //search writing_lock data
     foreach ($article->getMetaData() as $meta) {
         if ($meta->getKey() == 'writing_locked') {
             $metaLock = $meta;
             break;
         }
     }
     return $metaLock;
 }
Exemplo n.º 2
0
 public function loadArticle(ArticleInterface &$destination, ArticleInterface $src, $skipSlug = false, $skipMetaData = false)
 {
     $destination->setContent($src->getContent())->setTitle($src->getTitle())->setExcerpt($src->getExcerpt())->setExcerptPhoto($src->getExcerptPhoto())->setAuthor($src->getAuthor())->setCategories($src->getCategories())->setTags($src->getTags());
     if (!$skipMetaData) {
         //remove old metaData
         foreach ($destination->getMetaData() as $destMeta) {
             if ($src->getMetaByKey($destMeta->getKey()) === false) {
                 $destination->removeMetaData($destMeta);
             }
         }
         //add new metaData
         foreach ($src->getMetaData() as $srcMeta) {
             if ($destination->hasMetaData($srcMeta) === false && $srcMeta->getKey() != 'writing_locked') {
                 $destMeta = $destination->getMetaByKey($srcMeta->getKey());
                 if ($destMeta === false) {
                     $metaDataClass = $this->metaDataClass;
                     $destMeta = new $metaDataClass();
                 }
                 $destMeta->setKey($srcMeta->getKey())->setValue($srcMeta->getValue())->setArticle($destination);
                 $destination->addMetaData($destMeta);
             }
         }
     }
     if (!$skipSlug) {
         $destination->setSlug($src->getSlug());
     }
 }