示例#1
0
 protected function matchesCriteria(ScribbleFile $scribble, Criteria $criteria)
 {
     if (!$scribble) {
         return false;
     }
     if ($criteria->getSlug() !== null) {
         if ($scribble->getSlug() !== $criteria->getSlug()) {
             return false;
         }
     }
     // unpublished scribbles only
     if ($criteria->getMode() === Criteria::MODE_UNPUBLISHED) {
         if ($scribble->isPublished()) {
             return false;
         }
     } else {
         if ($criteria->getMode() === Criteria::MODE_ALL) {
         } else {
             if (!$scribble->isPublished()) {
                 return false;
             }
         }
     }
     foreach ($criteria->getTags() as $key => $tag) {
         if (!$scribble->getTags()->containsKey($key)) {
             return false;
         }
     }
     if ($criteria->getFind() && !$scribble->find($criteria->getFind())) {
         return false;
     }
     return true;
 }
示例#2
0
 public function getOne(Criteria $criteria)
 {
     // overwrite config defaults?
     $mode = $criteria->getMode() ? $criteria->getMode() : $this->mode;
     // criteria
     $criteria->setMode($mode);
     // get all scribbles
     $allScribbles = $this->getDirectory()->load()->getScribbles();
     // filter and paginate
     $filter = new Filter();
     $scribbles = $filter->apply($allScribbles, $criteria)->getScribbles();
     return $scribbles->first();
 }