Eccube\Repository\PageLayoutRepository::findUnusedBlocks PHP Метод

findUnusedBlocks() публичный Метод

public findUnusedBlocks ( Eccube\Entity\Master\DeviceType $DeviceType, $pageId )
$DeviceType Eccube\Entity\Master\DeviceType
    public function findUnusedBlocks(DeviceType $DeviceType, $pageId)
    {
        $em = $this->getEntityManager();
        $blockRepo = $em->getRepository('Eccube\\Entity\\Block');
        $ownBlockPositions = $this->get($DeviceType, $pageId)->getBlockPositions();
        $ids = array();
        foreach ($ownBlockPositions as $ownBlockPosition) {
            $ids[] = $ownBlockPosition->getBlock()->getId();
        }
        # $idsが空配列だと、$ids以外のblockを取得するSQLが生成されないため、存在しないidを入れる
        if (empty($ids)) {
            $ids[] = \Eccube\Entity\Block::UNUSED_BLOCK_ID;
        }
        return $blockRepo->createQueryBuilder('b')->where('b.id not in (:ids)')->setParameter(':ids', $ids)->getQuery()->getResult();
    }