Ejemplo n.º 1
0
 /**
  * Finds first available image for listing purposes
  *
  * @param Content $content
  *
  * @return string
  */
 public function getCoverImage(Content $content)
 {
     $key = $content->getCoverImageCacheKey();
     if (!($image = $this->cache->fetch($key))) {
         $image = $content->getCoverImage();
         if ($image) {
             $image = $this->imageCacheManager->getBrowserPath($image, 'medialibrary');
         }
         $this->cache->save($key, $image, 86400);
     }
     return $image;
 }
 /**
  * Finds first available image for listing purposes TODO: this is very inefficient
  *
  * @param Content $content
  *
  * @return string
  */
 public function getCoverImage(Content $content)
 {
     if ($content->getBlock() === null) {
         return false;
     }
     foreach ($content->getBlock()->getOwning() as $block) {
         $reflect = new \ReflectionClass($block);
         if ($reflect->hasProperty('media') && $block->getMedia()) {
             return $block->getMedia()->getReference();
         }
     }
     return false;
 }
 /**
  * Finds first available image for listing purposes
  *
  * @param Content $content
  *
  * @return string
  */
 public function getCoverImage(Content $content)
 {
     foreach ($content->getValueSet()->getValues() as $value) {
         switch (get_class($value)) {
             case 'Opifer\\EavBundle\\Entity\\NestedValue':
                 foreach ($value->getNested() as $nested) {
                     if (false !== ($cv = $this->getCoverImage($nested))) {
                         return $cv;
                     }
                 }
                 break;
             case 'Opifer\\EavBundle\\Entity\\MediaValue':
                 foreach ($value->getMedias() as $media) {
                     return $media->getReference();
                     break;
                 }
                 break;
         }
     }
     return false;
 }
 /**
  * Find related content
  *
  * @param Content $content
  * @param integer $limit
  *
  * @return \Doctrine\Common\Collections\ArrayCollection
  */
 public function findRelated(Content $content, $limit = 10)
 {
     $query = $this->createQueryBuilder('c')->innerJoin('c.valueSet', 'vs')->innerJoin('vs.values', 'v')->innerJoin('v.attribute', 'a')->andWhere('c.active = 1')->andWhere('c.nestedIn IS NULL')->andWhere('c.id <> :id')->setParameter('id', $content->getId())->setParameter('city', $city)->setMaxResults($limit)->getQuery();
     return $query->getResult();
 }
Ejemplo n.º 5
0
 private function getContentWithSchema()
 {
     $schema = new Schema();
     $valueSet = new ValueSet();
     $valueSet->setSchema($schema);
     $content = new Content();
     $content->setValueSet($valueSet);
     return $content;
 }
 /**
  * Finds first available image for listing purposes TODO: this is very inefficient
  *
  * @param Content $content
  *
  * @return string
  */
 public function getCoverImage(Content $content)
 {
     return $content->getCoverImage();
 }
Ejemplo n.º 7
0
 private function getContentWithTemplate($presentation = null)
 {
     $template = new Template();
     $template->setPresentation($presentation);
     $valueSet = new ValueSet();
     $valueSet->setTemplate($template);
     $content = new Content();
     $content->setValueSet($valueSet);
     return $content;
 }