public function getByUrl(DeviceType $DeviceType, $url)
{
$options = $this->app['config']['doctrine_cache'];
$lifetime = $options['result_cache']['lifetime'];
$qb = $this->createQueryBuilder('p')->select('p, bp, b')->leftJoin('p.BlockPositions', 'bp', 'WITH', 'p.id = bp.page_id')->leftJoin('bp.Block', 'b')->andWhere('p.DeviceType = :DeviceType AND p.url = :url')->addOrderBy('bp.target_id', 'ASC')->addOrderBy('bp.block_row', 'ASC');
$ownResult = $qb->getQuery()->useResultCache(true, $lifetime)->setParameters(array('DeviceType' => $DeviceType, 'url' => $url))->getSingleResult();
$qb = $this->createQueryBuilder('p')->select('p, bp, b')->leftJoin('p.BlockPositions', 'bp', 'WITH', 'p.id = bp.page_id')->leftJoin('bp.Block', 'b')->andWhere('p.DeviceType = :DeviceType AND bp.anywhere = 1')->addOrderBy('bp.target_id', 'ASC')->addOrderBy('bp.block_row', 'ASC');
$anyResults = $qb->getQuery()->useResultCache(true, $lifetime)->setParameters(array('DeviceType' => $DeviceType))->getResult();
$OwnBlockPosition = $ownResult->getBlockPositions();
foreach ($anyResults as $anyResult) {
$BlockPositions = $anyResult->getBlockPositions();
foreach ($BlockPositions as $BlockPosition) {
if (!$OwnBlockPosition->contains($BlockPosition)) {
$ownResult->addBlockPosition($BlockPosition);
}
}
}
return $ownResult;
}