Skip to content

Instantly share code, notes, and snippets.

@oaltman
Created September 20, 2013 08:42
Show Gist options
  • Save oaltman/6634851 to your computer and use it in GitHub Desktop.
Save oaltman/6634851 to your computer and use it in GitHub Desktop.
abstract class ContentDao extends EntityDao
{
protected $imageType;
public function __construct($imageType)
{
$this->imageType = $imageType;
}
public function getImageType()
{
$qb = $this->createQueryBuilder();
$query = $qb->select('type')
->from('\App\Cropper\ImageType','type')
->where('type.name = :name')
->getQuery()
->setParameter('name',$this->imageType);
return $query->getOneOrNullResult();
}
public function getPossibleImages()
{
$qb = $this->createQueryBuilder();
$query = $qb->select('thumbnail')
->from('\App\Thumbnail\Thumbnail','thumbnail')
->from('\App\Cropper\Image','image')
->from('\App\Cropper\ImageType','type')
->where('image.imageType = type')
->andWhere('thumbnail.image = image')
->andWhere('type.name = :name')
->getQuery()
->setParameter('name', $this->imageType);
return $query->execute();
}
public function getUnpublished()
{
return $this->findBy(array('published' => false),array());
}
public function getPublished()
{
return $this->findBy(array('published' => true),array());
}
}
class ShowDao extends ContentDao
{
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment