public function get(DeviceType $DeviceType, $pageId)
{
$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.id = :pageId')->addOrderBy('bp.target_id', 'ASC')->addOrderBy('bp.block_row', 'ASC');
$ownResult = $qb->getQuery()->setParameters(array('DeviceType' => $DeviceType, 'pageId' => $pageId))->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()->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;
}