Esempio n. 1
0
 /**
  * @return NotBlank
  */
 public function validate()
 {
     $height = array();
     $width = array();
     foreach ($this->dimensionContainer->getDimensions() as $dimension) {
         if ($dimension->getFixedHeight() > 0) {
             $height[] = $dimension->getFixedHeight();
         }
         if ($dimension->getMinHeight() > 0) {
             $height[] = $dimension->getMinHeight();
         }
         if ($dimension->getFixedWidth() > 0) {
             $width[] = $dimension->getFixedWidth();
         }
         if ($dimension->getMinWidth() > 0) {
             $width[] = $dimension->getMinWidth();
         }
     }
     if ($this->attachment->getWidth() > 0 && count($height) > 0) {
         if (max($height) > $this->attachment->getHeight() || max($width) > $this->attachment->getWidth()) {
             return new TranslatorObject('bigfish.media.error.minsize', array('%min_width%' => max($width), '%min_height%' => max($height), '%currentWidth%' => $this->attachment->getWidth(), '%currentHeight%' => $this->attachment->getHeight()));
         }
     }
     return true;
 }
 public function findDimensions(array $ids)
 {
     $qb = $this->getEntityManager()->createQueryBuilder();
     $qb->select('ImageDimension');
     $qb->from('BigfishMediaBundle:ImageDimension', 'ImageDimension')->where($qb->expr()->in('ImageDimension.id', ':ids'))->setParameter('ids', $ids);
     $query = $qb->getQuery();
     $result = $query->getResult();
     $oDimensions = new DimensionContainer();
     foreach ($result as $dimension) {
         $oDimensions->addDimension($dimension);
     }
     return $oDimensions;
 }