lib/Persistence/Doctrine/QueryHandler/BlockQueryHandler.php
public function moveBlock(Block $block, Block $targetBlock, string $placeholder, int $position): void
    {
        $query = $this->connection->createQueryBuilder();

        $query
            ->update('ngbm_block')
            ->set('position', ':position')
            ->set('parent_id', ':parent_id')
            ->set('placeholder', ':placeholder')
            ->where(
                $query->expr()->eq('id', ':id')
            )
            ->setParameter('id', $block->id, Type::INTEGER)
            ->setParameter('position', $position, Type::INTEGER)
            ->setParameter('parent_id', $targetBlock->id, Type::INTEGER)
            ->setParameter('placeholder', $placeholder, Type::STRING);

        $this->applyStatusCondition($query, $block->status);

        $query->execute();

        $depthDifference = $block->depth - ($targetBlock->depth + 1);

        $query = $this->connection->createQueryBuilder();

        $query
            ->update('ngbm_block')
            ->set('layout_id', ':layout_id')
            ->set('depth', 'depth - :depth_difference')
            ->set('path', 'replace(path, :old_path, :new_path)')
            ->where(
                $query->expr()->like('path', ':path')
            )
            ->setParameter('layout_id', $targetBlock->layoutId, Type::INTEGER)
            ->setParameter('depth_difference', $depthDifference, Type::INTEGER)
            ->setParameter('old_path', $block->path, Type::STRING)
            ->setParameter('new_path', $targetBlock->path . $block->id . '/', Type::STRING)
            ->setParameter('path', $block->path . '%', Type::STRING);

        $this->applyStatusCondition($query, $block->status);

        $query->execute();
    }
public function moveBlock(Block $block, Block $targetBlock, string $placeholder, int $position): void
    {
        $query = $this->connection->createQueryBuilder();

        $query
            ->update('ngbm_block')
            ->set('position', ':position')
            ->set('parent_id', ':parent_id')
            ->set('placeholder', ':placeholder')
            ->where(
                $query->expr()->eq('id', ':id')
            )
            ->setParameter('id', $block->id, Type::INTEGER)
            ->setParameter('position', $position, Type::INTEGER)
            ->setParameter('parent_id', $targetBlock->id, Type::INTEGER)
            ->setParameter('placeholder', $placeholder, Type::STRING);

        $this->applyStatusCondition($query, $block->status);

        $query->execute();

        $depthDifference = $block->depth - ($targetBlock->depth + 1);

        $query = $this->connection->createQueryBuilder();

        $query
            ->update('ngbm_block')
            ->set('layout_id', ':layout_id')
            ->set('depth', 'depth - :depth_difference')
            ->set('path', 'replace(path, :old_path, :new_path)')
            ->where(
                $query->expr()->like('path', ':path')
            )
            ->setParameter('layout_id', $targetBlock->layoutId, Type::INTEGER)
            ->setParameter('depth_difference', $depthDifference, Type::INTEGER)
            ->setParameter('old_path', $block->path, Type::STRING)
            ->setParameter('new_path', $targetBlock->path . $block->id . '/', Type::STRING)
            ->setParameter('path', $block->path . '%', Type::STRING);

        $this->applyStatusCondition($query, $block->status);

        $query->execute();
    }
public function moveBlock ( Block $ block , Block $ targetBlock , string $ placeholder , int $ position ) : void { $ query = $ this -> connection -> createQueryBuilder ( ) ; $ query -> update ( 'ngbm_block' ) -> set ( 'position' , ':position' ) -> set ( 'parent_id' , ':parent_id' ) -> set ( 'placeholder' , ':placeholder' ) -> where ( $ query -> expr ( ) -> eq ( 'id' , ':id' ) ) -> setParameter ( 'id' , $ block -> id , Type :: INTEGER ) -> setParameter ( 'position' , $ position , Type :: INTEGER ) -> setParameter ( 'parent_id' , $ targetBlock -> id , Type :: INTEGER ) -> setParameter ( 'placeholder' , $ placeholder , Type :: STRING ) ; $ this -> applyStatusCondition ( $ query , $ block -> status ) ; $ query -> execute ( ) ; $ depthDifference = $ block -> depth - ( $ targetBlock -> depth + 1 ) ; $ query = $ this -> connection -> createQueryBuilder ( ) ; $ query -> update ( 'ngbm_block' ) -> set ( 'layout_id' , ':layout_id' ) -> set ( 'depth' , 'depth - :depth_difference' ) -> set ( 'path' , 'replace(path, :old_path, :new_path)' ) -> where ( $ query -> expr ( ) -> like ( 'path' , ':path' ) ) -> setParameter ( 'layout_id' , $ targetBlock -> layoutId , Type :: INTEGER ) -> setParameter ( 'depth_difference' , $ depthDifference , Type :: INTEGER ) -> setParameter ( 'old_path' , $ block -> path , Type :: STRING ) -> setParameter ( 'new_path' , $ targetBlock -> path . $ block -> id . '/' , Type :: STRING ) -> setParameter ( 'path' , $ block -> path . '%' , Type :: STRING ) ; $ this -> applyStatusCondition ( $ query , $ block -> status ) ; $ query -> execute ( ) ; }
Moves a block. If the target block is not provided, the block is only moved within its
current parent ID and placeholder.
Moves a block . If the target block is not provided the block is only moved within its current parent ID and placeholder .